Matlab pyversion命令找不到适用于python3.4的库 [英] Matlab pyversion command can not find library for python3.4

查看:198
本文介绍了Matlab pyversion命令找不到适用于python3.4的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从matlab调用python3.4.默认版本是python2.7,当我在matlab中运行pyversion时,它显示:

I want call python3.4 from the matlab. The default version is python2.7, when I run pyversion in matlab, it shows :

   version: '2.7'
executable: '/usr/bin/python'
   library: 'libpython2.7.so.1.0'
      home: '/usr'
  isloaded: 0

并且我通过在Matlab中运行py.list()进行了测试,它可以正常工作.

and I tested by run py.list() in matlab, it works.

然后我想将版本更改为python3,所以我运行

Then I want to change the version to python3, so I run

pyversion(/usr/bin/python3)

更改python的版本.

to change the version of python.

但是现在说py.list()不能用,说Undefined variable "py" or class "py.list".. 另外,现在我运行pyversion,信息显示:

But now py.list() can not works, is said Undefined variable "py" or class "py.list".. Additionally, now I run pyversion, the information shows :

version: '3.4'
executable: '/usr/bin/python3.4'
library: ''
home: '/usr'
isloaded: 0

库"为空.

如何解决此问题以正确运行python3.4?

How could I solve this to run python3.4 correctly?

我使用Ubuntu 14.04,并且已经为python3.4安装了Cython.通过运行find /usr/lib -name libpython*

I use Ubuntu 14.04 and I have installed Cython for python3.4. I have the following output by running find /usr/lib -name libpython*

/usr/lib/python3.4/config-3.4dm-x86_64-linux-gnu/libpython3.4.so
/usr/lib/python3.4/config-3.4dm-x86_64-linux-gnu/libpython3.4dm.so
/usr/lib/python3.4/config-3.4dm-x86_64-linux-gnu/libpython3.4dm.a
/usr/lib/python3.4/config-3.4m-x86_64-linux-gnu/libpython3.4.so
/usr/lib/python3.4/config-3.4m-x86_64-linux-gnu/libpython3.4m.a
/usr/lib/python3.4/config-3.4m-x86_64-linux-gnu/libpython3.4m.so
/usr/lib/python3.4/config-3.4m-x86_64-linux-gnu/libpython3.4m-pic.a
/usr/lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so
/usr/lib/python2.7/config-x86_64-linux-gnu/libpython2.7.a
/usr/lib/python2.7/config-x86_64-linux-gnu/libpython2.7-pic.a
/usr/lib/libpeas-1.0/loaders/libpython3loader.so
/usr/lib/libpeas-1.0/loaders/libpythonloader.so
/usr/lib/debug/usr/lib/libpython3.4m.so.1.0-gdb.py
/usr/lib/debug/usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0
/usr/lib/libreoffice/program/libpythonloaderlo.so
/usr/lib/x86_64-linux-gnu/libpython3.4m.so.1
/usr/lib/x86_64-linux-gnu/libpython3.4dm.so.1
/usr/lib/x86_64-linux-gnu/libpython3.4m.a
/usr/lib/x86_64-linux-gnu/libpython2.7.so
/usr/lib/x86_64-linux-gnu/libpython3.4m.so
/usr/lib/x86_64-linux-gnu/libpython3.4dm.so.1.0
/usr/lib/x86_64-linux-gnu/libpython2.7.a
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1
/usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0
/usr/lib/x86_64-linux-gnu/libpython3.4dm.so
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
/usr/lib/x86_64-linux-gnu/libpython3.4dm.a

推荐答案

恰好在本文发布后的5天内有同样的问题.

Just so happened to have the same issue within 5 days of this post.

显然,matlab使用以下脚本搜索该库:

Apparently matlab uses the following script to search for the library:

MATLABROOT/toolbox/matlab/external/interfaces/python/+ python/+ internal/pyinfo.py

MATLABROOT/toolbox/matlab/external/interfaces/python/+python/+internal/pyinfo.py

其中的MATLABROOT是在安装matlab时选择的.

where MATLABROOT is something you chose when you installed matlab.

从理论上讲,您可以编辑pyinfo.py以在搜索中包含'/usr/lib/x86_64-linux-gnu'.例如,通过将另一种方法附加到仅返回"/usr/lib/x86_64-linux-gnu"的搜索位置.但是我不知道这样做会在许可/法律/保修方面产生什么影响,因此请您自行决定使用它.

Theoretically, you could edit pyinfo.py to include '/usr/lib/x86_64-linux-gnu' in its search. For example, by appending one more method to the search locations that just returns '/usr/lib/x86_64-linux-gnu'. But I don't know what the licensing/legal/warranty ramifications of this would be, so use at your own discretion.

这篇关于Matlab pyversion命令找不到适用于python3.4的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆