pyenv Library property empty. Unable to resolve the name (Linux:Pop OS 22.04, python 3.9, R2022a)
Mostrar comentarios más antiguos
Hello All,
I've hit a wall trying to call python from MATLAB.
Since, MATLAB R2022a supports python 3.8 and 3.9 (ref) I've installed python3.9 via my system's package manager. (Note that python 3.10 was installed first, and is used system wide)
However, Python 3.9 is definitly working
$which python3.9
/usr/bin/python3.9
$python3.9 --version
Python 3.9.13
>>pyenv('Version','/usr/bin/python3.9')
ans =
PythonEnvironment with properties:
Version: "3.9"
Executable: "/usr/bin/python3.9"
Library: ""
Home: "/usr"
Status: NotLoaded
ExecutionMode: InProcess
Note, the library propery of the pyenv object is empty.
Then trying to force python to load by calling a simple python function yields:
>> py.print("Printed from python")
Unable to resolve the name 'py.print'.
I was able to replicate this issue on Ununtu 22.04 also with python3.9.
The closest related post I've found is on OSX, in which the user had a simmilar empty propery issue.
Can anyone advise on how to correct this, and get python calls working?
Thank you!
Respuesta aceptada
Más respuestas (1)
Al Danial
el 22 de Jul. de 2022
On my Ubuntu 20.04 system pyenv returns
>> pyenv
ans =
PythonEnvironment with properties:
Version: "3.9"
Executable: "/usr/local/anaconda3/2021.05/envs/matpy/bin/python"
Library: "/usr/local/anaconda3/2021.05/envs/matpy/lib/libpython3.9.so"
Home: "/usr/local/anaconda3/2021.05/envs/matpy"
Status: Loaded
ExecutionMode: InProcess
ProcessID: "1527848"
ProcessName: "MATLAB"
so try finding the libpython3.9.so shared library and explicitly setting the Library field with that path. For example on my system that would be
>> pyenv('Library','/usr/local/anaconda3/2021.05/envs/matpy/lib/libpython3.9.so')
If your Python shared libraries for both 3.9 and 3.10 exist in the same directory I can see how that will cause you grief. Ideally you'd your 3.9 installation would live in its own directory. I don't know if apt install gives you that freedom if that's what you did. My recommendation is to uninstall 3.9 then install Anaconda Python since that lets you control the location.
1 comentario
Jorian Khan
el 23 de Jul. de 2022
Categorías
Más información sobre Call Python from MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!