Unable to resolve py.sys.path
36 views (last 30 days)
Show older comments
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 Comment
Al Danial
on 30 Jul 2023
Which version of matlab? The matlab and Python versions need to match per https://www.mathworks.com/support/requirements/python-compatibility.html
Answers (1)
Sanjana
on 22 Aug 2023
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.
0 Comments
See Also
Categories
Find more on Call Python from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!