python - 使用 MATLAB 代码创建 python 应用程序时出错 (LD_LIBRARY_PATH)

标签 python matlab ubuntu

我阅读了以下说明,以便使用 matlab 代码创建 python 应用程序:Create a Python Application with MATLAB Code

一切正常,当我执行命令python setup.py install时,会显示以下消息:

root@david:/home/david/Desktop/Matrices_Clifford/for_redistribution_files_only# python setup.py install
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/Matrices_Clifford
copying Matrices_Clifford/__init__.py -> build/lib.linux-x86_64-2.7/Matrices_Clifford
copying Matrices_Clifford/Matrices_Clifford.ctf -> build/lib.linux-x86_64-2.7/Matrices_Clifford
running install_lib
creating /usr/local/lib/python2.7/dist-packages/Matrices_Clifford
copying build/lib.linux-x86_64-2.7/Matrices_Clifford/Matrices_Clifford.ctf -> /usr/local/lib/python2.7/dist-packages/Matrices_Clifford
copying build/lib.linux-x86_64-2.7/Matrices_Clifford/__init__.py -> /usr/local/lib/python2.7/dist-packages/Matrices_Clifford
byte-compiling /usr/local/lib/python2.7/dist-packages/Matrices_Clifford/__init__.py to __init__.pyc
running install_egg_info
Removing /usr/local/lib/python2.7/dist-packages/matlabruntimeforpython-R2017a.egg-info
Writing /usr/local/lib/python2.7/dist-packages/matlabruntimeforpython-R2017a.egg-info
removing 'build/lib.linux-x86_64-2.7' (and everything under it)
'build/bdist.linux-x86_64' does not exist -- can't clean it
'build/scripts-2.7' does not exist -- can't clean it
removing 'build'

然后,当我尝试导入 Matrices_Clifford 时出现错误:

import Matrices_Clifford
    Exception caught during initialization of Python interface. Details: On Linux, you must set the environment variable "LD_LIBRARY_PATH" to a non-empty string. For more details, see the package documentation.
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "Matrices_Clifford/__init__.py", line 276, in <module>
        _pir.get_paths_from_os()
      File "Matrices_Clifford/__init__.py", line 171, in get_paths_from_os
        friendly_os_name, self.path_var, 'For more details, see the package documentation.'))
    RuntimeError: On Linux, you must set the environment variable "LD_LIBRARY_PATH" to a non-empty string. For more details, see the package documentation.

如何解决这个问题?

最佳答案

这个错误是不言自明的。必须定义环境变量LD_LIBRARY_PATH,以便操作系统知道库的位置。使用setenv command正确定义它,如下所示:

setenv LD_LIBRARY_PATH path/to/libraries

看来this link可以为您指明正确的路径(没有双关语),并且所需位置的格式为 matlabroot/bin/glnxa64:matlabroot/sys/os/glnxa64

关于python - 使用 MATLAB 代码创建 python 应用程序时出错 (LD_LIBRARY_PATH),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48844547/

相关文章:

python - 从 zip 复制文件并同时读取该文件

javascript - 使用 Flask 在 HTML/JS 上渲染 SQL 数据

python - 用一维数组中的值替换二维数组中的填充值

matlab - 如何使用可变大小的原始图像 block 来训练 SVM?

matlab - 设置大于屏幕的 matlab 图

ruby-on-rails - rails-installer.sh 运行正常但 ruby​​、irb、rails 命令 "not found"(UB12.04)

ubuntu - Couchbase C SDK 安装问题

python - 使用 ASN.1 解码,其中 substrate 包含一些不透明数据

matlab - 在切片中绘制 3d 矩阵 - MATLAB

linux - ubuntu 拒绝 postgres 连接