Unable to run basic python commands despite building python with --enabled-shared on macOS Monterey

3 次查看(过去 30 天)
I've been building python locally to run with matlab. I have successfully built python in version 3.8.12, and 3.10.0 with the enabled-shared flag and created a virtual python enviroment using the venv package with the enviroment being called 'python-env'. I have sucessfully pointed to the right executable in matlab using the pyenv command and get the output shown below. But calling simple commands like py.open, or py.print("Hello") fail with the error line "Unable to resolve the name 'py.print'."
ans =
PythonEnvironment with properties:
Version: "3.8"
Executable: "/Users/adammurdock/Programming_Stuff/Reverb Project/python-env/bin/python"
Library: "/Users/adammurdock/.pyenv/versions/3.8.12/lib/libpython3.8.dylib"
Home: "/Users/adammurdock/Programming_Stuff/Reverb Project/python-env"
Status: NotLoaded
ExecutionMode: OutOfProcess

回答(1 个)

Dinesh
Dinesh 2023-6-5
编辑:Dinesh 2023-6-5
Hello Adam,
If you encounter the error message 'Unable to resolve the name py.myFuncName' in MATLAB, it may be caused by installation issues related to Python. One possible reason for this error is a compatibility issue between Python and MATLAB. Specifically, only Python 3.10 is compatible with MATLAB R2023a and R2022b.
To resolve this issue, I recommend that you review the following MATLAB documentation. This should provide you with the necessary information to troubleshoot and fix the error.
  1. Configure Your System to Use Python
  2. Unable to resolve the name py.myfunc
  3. Versions of Python Compatible with MATLAB Products by Release
  4. Python virtual environments with MATLAB
Hope this helps!
Thank you.

类别

Help CenterFile Exchange 中查找有关 Call Python from MATLAB 的更多信息

标签

产品


版本

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by