Why Matlab does not see Python?

I am trying to luch the python file using the pyrunfile, but got an error.
Verificatio of the python version all shows me the answer (see below), nevertheless that in comandn line i see Version 3.8.3:
What is the problem?
Thanks in advance
In Matlab:
>> pyversion
version: ''
executable: ''
library: ''
home: ''
isloaded: 0
CMD:
C:\Users\Sarr>python --version
Python 3.8.3

Réponses (4)

Yongjian Feng
Yongjian Feng le 23 Fév 2022
matlab uses PATH env var to find python. Your python installation is in a local path. Try this in matlab command line:
getenv('PATH')
If the path to your python is not there, then set the PATH env var in matlab command line
setenv('PATH', new_path_with_python_location_added)

4 commentaires

Sergii Snegir
Sergii Snegir le 23 Fév 2022
Dear Yongjian,
many thanks for the answer
getenv('PATH')
give me the following:
'C:\Program Files (x86)\Python38-32\Scripts\;C:\Program Files (x86)\Python38-32\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\MATLAB\R2021b\bin;C:\Program Files\MATLAB\R2021a\bin;C:\Program Files\MATLAB\R2020b\bin;C:\Program Files\MATLAB\R2019b\runtime\win64;C:\Program Files\MATLAB\R2019b\bin;C:\Program Files\IVI Foundation\VISA\Win64\Bin\;C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin\;C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Users\Sergii\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;'
What should I do next? ( sorry, but i did not get really)
Yongjian Feng
Yongjian Feng le 23 Fév 2022
Modifié(e) : Yongjian Feng le 23 Fév 2022
Please try this:
ori_path = getenv('PATH')
new_path = [ori_path ';C\Users\Sarr']; % This appends the path to your python to the ori path
setenv('PATH', new_path); % update PATH env var
pvversion % check pvversion again
Sergii Snegir
Sergii Snegir le 24 Fév 2022
thanks. I have tried.
The result is:
Yongjian Feng
Yongjian Feng le 24 Fév 2022
Sean suggested that you might need to check if you have installed a 32bit python. Start python from Windows command line like this. Your path shown above really looks like a 32bit. If so, you need to install a 64bit python to make it work.

Connectez-vous pour commenter.

Abdurrahman Dayi
Abdurrahman Dayi le 23 Fév 2022

0 votes

It might be the case that you are using a Matlab version that does not support python 3.8.
Kindly double check the supported python versions for your matlab version here: https://www.mathworks.com/content/dam/mathworks/mathworks-dot-com/support/sysreq/files/python-compatibility.pdf

1 commentaire

Sergii Snegir
Sergii Snegir le 23 Fév 2022
Thnaks for the answer. The version I have 2021b has to work with python 3.8 (according to support info)

Connectez-vous pour commenter.

Sean de Wolski
Sean de Wolski le 23 Fév 2022

0 votes

Looks like you have 32-bit python. You need 64-bit Python.
Julian
Julian le 17 Août 2023

0 votes

Have you tried installing Python not locally for your user, but for all users?
I have the same problem and wanted to try that now. Unfortunately I then no longer have my current environments.

Catégories

Produits

Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by