Wednesday, 8 January 2020

Getting MATLAB R2019b to use Python3.6

I am trying to use python 3.6 within the MATLAB interpreter. I have both Python 2.7 and 3.6 installed on my machine. When using the default python 2.7 MATLAB work fine:

>> pyenv('Version', '/usr/bin/python')

ans =

PythonEnvironment with properties:

      Version: "2.7"
   Executable: "/usr/bin/python"
      Library: "libpython2.7.so.1.0"
         Home: "/usr"
       Status: NotLoaded
ExecutionMode: InProcess

>> py.sys.version

ans =

Python str with no properties.

2.7.5 (default, Aug  7 2019, 00:51:29)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]

However when following MATLAB's directions to change versions of python by entering the path of the python 3 executable file, python will not load:

>> pyenv('Version', '/opt/rh/rh-python36/root/usr/bin/python3.6')

ans =

 PythonEnvironment with properties:

      Version: "3.6"
   Executable: "/opt/rh/rh-python36/root/usr/bin/python3.6"
      Library: ""
         Home: "/opt/rh/rh-python36/root/usr"
       Status: NotLoaded
ExecutionMode: InProcess

>> py.sys.version
Unable to resolve the name py.sys.version.

I do notice that the library field in pyenv is not filled in for python 3. So it appears that MATLAB cannot find a python 3 shared object file. Why would MATLAB have problems finding the libpython shared object file?



from Getting MATLAB R2019b to use Python3.6

No comments:

Post a Comment