Error 'Python est introuvable'

35 次查看(过去 30 天)
Nathalie Brun
Nathalie Brun 2021-6-28
回答: Tejas 2024-2-23
Hi
I am on Windows 10
I configured the environment such as :
Status: Loaded
ExecutionMode: InProcess
ProcessID: "8804"
ProcessName: "MATLAB"
When I try to run the Python code with :
system('python python/vae_keras_ems_train.py')
I get the message :
Python est introuvable. ExÚcutez sans argument pour procÚder Ó l
ans =
9009
Thanks !

回答(1 个)

Tejas
Tejas 2024-2-23
Hello Nathalie,
It seems you are encountering the "Python not found" issue. To resolve this, please follow the steps outlined below.
Firstly, ensure that the version of Python you are using is compatible with your MATLAB version. You can refer to the following documentation for guidance: https://www.mathworks.com/support/requirements/python-compatibility.html?s_tid=srchtitle_site_search_1_python%20compatibility#:~:text=3.7%2C%203.8%2C%203.9-,R2021a,-2.7%2C%203.7%2C%203.8 .
Next, verify that Python is added to the "Environment Path" variables. If it is not, you can add it by going to the Start Menu, typing "Edit environment variables for your account," and then selecting "Path" under User variables. Click "Edit" and enter the path to your Python executable.
Now, in the MATLAB command window, type the following command:
>> pyenvpyenv( 'Version', 'path_to_python_executable', 'ExecutionMode', 'OutOfProcess');
This command will link Python to MATLAB. To verify whether the linking is successful, type the following command in the MATLAB command window:
>> pyenv
This will display the Python version and the path to the Python executable file.
Ensure that you add the Python file you wish to run to the MATLAB path. This will enable you to successfully execute the Python file using the "system" function call.
To learn more about pyenv function, follow the guidelines in this documentation:
Hope it helps!

类别

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

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by