Why do I get a "Python commands require a supported version of CPython." error when I have a compatible version installed?
Ältere Kommentare anzeigen
Hello, I am trying to run python commands in matlab. I have installed Matlab version 2023a and Python 3.10.0, which should be compatible according to the documentation here Versions of Python Compatible with MATLAB Products by Release - MATLAB & Simulink (mathworks.com). I have run the setup.py command in the "...\extern\engines\python folder" as required, and the error message about not recognising py.list has disappeared, indicating the install was successful. I now get an error message saying "Python commands require a supported version of CPython" when I type "py.list", despite having a compatible version ("pyenv" returns version 3.10). Can anyone suggest anything else I could try? Thanks, Olie
Akzeptierte Antwort
Weitere Antworten (1)
Adithya
am 27 Mär. 2023
0 Stimmen
It's possible that your MATLAB installation is not detecting your Python installation properly. Here are a few things you can try:
1. Check that your Python installation is in your system's PATH environment variable. You can do this by opening a command prompt or terminal and typing "python". If Python starts up, then it's in your PATH.
2. In MATLAB, try running the following command to check which Python interpreter MATLAB is using:
>>pyversion
3.Try reinstalling the MATLAB Engine API for Python. To do this, open a command prompt or terminal and navigate to the "...\extern\engines\python" folder. Then run the following command:
>>python setup.py install --prefix=<matlab_root>/extern/engines/python
Be sure to replace "<matlab_root>" with the root directory of your MATLAB installation.
4. If the above steps don't work, you can try adding the path to your Python executable manually in MATLAB. You can do this by running the following command:
pyversion('path/to/python')
Hopefully one of these solutions works for you.
Kategorien
Mehr zu Call Python from MATLAB finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!