导入ghmm库出错

发布于 2025-01-04 02:02:51 字数 928 浏览 2 评论 0原文

我收到此错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.6/dist-packages/ghmm.py", line 112, in <module>
    import ghmmwrapper
  File "/usr/local/lib/python2.6/dist-packages/ghmmwrapper.py", line 25, in <module>
    _ghmmwrapper = swig_import_helper()
  File "/usr/local/lib/python2.6/dist-packages/ghmmwrapper.py", line 21, in swig_import_helper
    _mod = imp.load_module('_ghmmwrapper', fp, pathname, description)
ImportError: libghmm.so.1: cannot open shared object file: No such file or directory

但是

root@ubuntu:~# sudo locate libghmm
/usr/local/lib/libghmm.a
/usr/local/lib/libghmm.la
/usr/local/lib/libghmm.so
/usr/local/lib/libghmm.so.1
/usr/local/lib/libghmm.so.1.0.0

为什么我收到此错误?我尝试添加

/usr/local/lib/

到我的 PYTHONPATH

但它不起作用。

i get this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.6/dist-packages/ghmm.py", line 112, in <module>
    import ghmmwrapper
  File "/usr/local/lib/python2.6/dist-packages/ghmmwrapper.py", line 25, in <module>
    _ghmmwrapper = swig_import_helper()
  File "/usr/local/lib/python2.6/dist-packages/ghmmwrapper.py", line 21, in swig_import_helper
    _mod = imp.load_module('_ghmmwrapper', fp, pathname, description)
ImportError: libghmm.so.1: cannot open shared object file: No such file or directory

but

root@ubuntu:~# sudo locate libghmm
/usr/local/lib/libghmm.a
/usr/local/lib/libghmm.la
/usr/local/lib/libghmm.so
/usr/local/lib/libghmm.so.1
/usr/local/lib/libghmm.so.1.0.0

Why go i get this error? i tried adding

/usr/local/lib/

to my PYTHONPATH

but it didn't work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

喜你已久 2025-01-11 02:02:51

PYTHONPATH 适用于 python 模块,不适用于系统库。

您可以将本地路径添加到系统:

  1. 以 root 身份编辑 /etc/ld.so.conf
  2. 添加新行 /usr/local/lib
  3. 保存并退出
  4. 运行“sudo ldconfig”

然后重新启动您的应用程序,它就会工作。

如果您不想对系统进行任何更改,可以使用环境变量:

LD_PRELOAD_PATH=/usr/local/lib python <yourapp.py>

PYTHONPATH is working for python modules, not for system libraries.

You can add the local path to your system:

  1. Edit as root /etc/ld.so.conf
  2. Add a new line with /usr/local/lib
  3. Save and quit
  4. Run "sudo ldconfig"

Then restart your application, it will work.

If you don't want to change anything to your system, you can use the environment variable:

LD_PRELOAD_PATH=/usr/local/lib python <yourapp.py>
瑕疵 2025-01-11 02:02:51
cd ~  
vi .bashrc  
#at the end of file add:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
# relogin terminal
cd ~  
vi .bashrc  
#at the end of file add:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
# relogin terminal
傾旎 2025-01-11 02:02:51

尝试仅执行 sudo ldconfig 来进行运行时绑定。

Try to just execute sudo ldconfig for run-time bindings.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文