Problem with Python version on Matlab R2018a
조회 수: 12 (최근 30일)
이전 댓글 표시
I have a MacBook Air, with Matlab 2018a installed.
I'm trying to change the default Python 2.7 version with Python 3.6, but in Matlab 2018a the function pyenv() is not aveilable. How can I change the Python version?
댓글 수: 0
답변 (1개)
Anavi Somani
2023년 7월 18일
Hi Alessandro, in MATLAB 2018a, the `pyenv()` function is not available to change the default Python version. However, you can still change the Python version used by MATLAB by following these steps:
1. Determine the location of the Python executable for the desired version (Python 3.6) on your system. Typically, it is located in `/usr/bin/python3` or `/usr/local/bin/python3`.
2. Open MATLAB and go to the "Home" tab.
3. Click on "Preferences" to open the MATLAB Preferences dialog box.
4. In the Preferences dialog box, select "Python" under "MATLAB" on the left-hand side.
5. In the "Python" section, click on the "Manage Configurations" button.
6. In the "Manage Configurations" dialog box, click on the "Add" button.
7. In the "Add Configuration" dialog box, provide a name for the new Python configuration (e.g., Python 3.6).
8. In the "Python Executable" field, enter the path to the Python executable for Python 3.6
(e.g., `/usr/bin/python3` or `/usr/local/bin/python3`).
9. Click "OK" to save the new Python configuration.
10. In the "Manage Configurations" dialog box, select the newly created Python configuration (Python 3.6) and click on the "Set as Default" button.
11. Close the Preferences dialog box.
Now, MATLAB will use the specified Python version (Python 3.6) as the default Python interpreter.
Please note that changing the default Python version in MATLAB may have implications for any existing scripts or functions that rely on the previous Python version. Make sure to test your code thoroughly after making this change.
참고 항목
카테고리
Help Center 및 File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!