Problem with Python version on Matlab R2018a
14 次查看(过去 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!