Unable to resolve py.sys.path

15 次查看(过去 30 天)
Max Salter
Max Salter 2023-7-26
回答: Sanjana 2023-8-22
I am trying to call a Python function from a MATLAB script, but no matter what function I call I get the error 'Unable to resolve the name py.function'. This includes when I run py.sys.path, I get the error 'Unable to resolve the name py.sys.path'. When I call pyenv, I get:
>> pyenv
ans =
PythonEnvironment with properties:
Version: "3.10"
Executable: "C:\Users\maxml\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe"
Library: "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\python310.dll"
Home: "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0"
Status: NotLoaded
ExecutionMode: OutOfProcess
My ultimate goal is just to call a Python function from within a MATLAB script. What could be causing this behavior? Thank you in advance!

回答(1 个)

Sanjana
Sanjana 2023-8-22
Hi Max,
I understand that you are facing an issue in calling a Python function from a MATLAB Script.As per the steps mentioned in the below documentation, the “Unable to resolve the name py.function” error occurs when the location of custom defined module containing the Python function is not added in the Python path or when the Python path itself is not added properly. To provide the path to the Python executable, use the “pyenv”.
Please refer to the following documentation for adding Python path,
Please refer to the following link, for further information on adding the Python module location in the Python path,
Hope this helps.
Regards,
Sanjana.

类别

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