"undefined Variable "py" Or Class" When Trying To Load Python From Matlab R2014b?
Solution 1:
If you get the error message below, a failure has occurred.
Undefined variable "py" or class
There are a lot of things that might be wrong here, and Mathworks have actually set up a whole tutorial for how to troubleshoot this problem. (The title of the page is actually: Undefined variable "py" or function "py.command", so it should contain most of what you need)
Check out the following:
- Python Not Installed
- 64-bit/32-bit Versions of Python on Windows Platforms
- MATLAB Cannot Find Python
- Error in User-Defined Python Module
- Python Module Not on Python Search Path
- Module Name Conflicts
- Python Tries to Execute command in Wrong Module
Solution 2:
Starting from Matlab 2014b Python functions can be called directly - using prefix py, then module name, and finally function name like so:
result = py.module_name.function_name(parameter1);
However, one has to make sure to add the script to the Python search path when calling from Matlab (especially if the first time Python is called the current working directory is different than that of the Python script.
See more details here.
Post a Comment for ""undefined Variable "py" Or Class" When Trying To Load Python From Matlab R2014b?"