Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab pyversion command can not find library for python3.4

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

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

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

pyversion(/usr/bin/python3)

to change the version of python.

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

the "library" becomes empty.

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

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
like image 764
alexxx Avatar asked Mar 10 '23 11:03

alexxx


2 Answers

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

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

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

where MATLABROOT is something you chose when you installed matlab.

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.

like image 120
user7809296 Avatar answered Apr 06 '23 00:04

user7809296


I ran into a similar issue (R2015b, Ubuntu) and did not solve it with the accepted answer. I had to execute

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

without modifying it from the command line to make it work.

like image 42
Bob le cinglé Avatar answered Apr 05 '23 23:04

Bob le cinglé