Reputation: 515
I'm trying to run Python from MATLAB, but when I try I got the message:
py.list({'Monday','Tuesday','Wednesday','Thursday','Friday'})
Unable to resolve the name py.list.
I also have tried pyenv
pyenv
ans =
PythonEnvironment with properties:
Version: "3.7"
Executable: "C:\Users\Familia\.conda\envs\matlab\python.exe"
Library: "C:\Users\Familia\.conda\envs\matlab\python37.dll"
Home: "C:\Users\Familia\.conda\envs\matlab"
Status: NotLoaded
ExecutionMode: InProcess
Could be my problem the Status? NotLoaded? How can I change that for Loaded? Since this path is with Conda, I also tried to change for another Python version I have installed without Anaconda, with this command:
pe = pyenv('Version','C:\Users\Familia\AppData\Local\Microsoft\WindowsApps\python.exe')
Error using pyenv
Path argument does not specify a valid executable.
How can I overcome that?
Upvotes: 0
Views: 5264
Reputation: 49
For people working on a network where the MATLAB you are using is installed on another users account you need to share your user's folder with the account that MATLAB is installed on.
Steps:
C:\Users
and right click on the folder with your usernameSharing
tab and click Share...
Add
, and select Find people...
OK
Upvotes: 0
Reputation: 57
It worked for me by using the path from a created conda environment exclusively having python 3.7 for Matlab 2021a. So the steps were:
conda create --name matlabpy python=3.7 #You can give any name to the env
Add the path where this "matlabpy" environment is located by clicking in "Set Path" in Matlab
Run py.list({'Monday','Tuesday','Wednesday','Thursday','Friday'})
Hope it works for you as well
Upvotes: 1
Reputation: 515
I manage to overcome that uninstalling python and installing again the 64bit, and during the installation, I chose to add python to the path environment and install for all users. That works for me.
Upvotes: 0
Reputation: 25999
Well, you are seeing that error because the path you specified is not valid.
Open a Command prompt window and type:
where python
this will return a list of locations of Python installations on your machine. On my machine, the command returns:
C:\Users\paolo\AppData\Local\Programs\Python\Python36\python.exe
so we can use this location when calling pyenv
in MATLAB:
>> pyenv('Version','C:\Users\paolo\AppData\Local\Programs\Python\Python36\python.exe')
then I can use py.list
:
>> py.list({'Monday','Tuesday','Wednesday','Thursday','Friday'})
ans =
Python list with no properties.
['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']
Upvotes: 2