python3.5 library does not show in pyversion

1 Ansicht (letzte 30 Tage)
Willy Bernal
Willy Bernal am 7 Feb. 2021
Beantwortet: Rushikesh am 9 Aug. 2024
I am running Matlab 2017a. It is supposed to support 2.7, 3.4, and 3.5. I can run 2.7 fine, but when I switch to 3.5, the library is empty. Do you have some suggestions on this?
In Matlab:
>> pyversion
version: '3.5'
executable: '/Users/wbernalh/.pyenv/versions/3.5.10/bin/python3'
library: ''
home: '/Users/wbernalh/.pyenv/versions/3.5.10'
isloaded: 0
In terminal:
$find /usr/lib -name libpython*
/usr/lib/libpython2.7.dylib
/usr/lib/libpython.dylib

Antworten (1)

Rushikesh
Rushikesh am 9 Aug. 2024
When using multiple python versions such errors commonly occurred. I have also come across similar issues where python libraries were not recognizing while using MATLAB.
This problem was most likely caused due to environment path issues. I would recommend following steps to solve the library field missing issue in MacOS.
Step 1. Verify Python Installation
You can use ‘which python3.5’ command in terminal to get python installation path.
If you found necessary library location in ‘lib’ folder of above path, then you can set python library path manually inside MATLAB using ‘pyversion’ function as
pyversion('Your path to python version /.pyenv/versions/3.5.10/bin/python3',
'Your path to python version /.pyenv/versions/3.5.10/lib/libpython3.5.dylib');
Step 2. Environment Path Check
Ensure that the Python executable and its libraries are correctly set in your system's PATH and PYTHONPATH. You can set this in your corresponding configuration files (.bashrcfor Bash or.zshrcfor Zsh).
Open the file in text editor as
nano ~/.bashrc
And set thePATHandPYTHONPATHenvironment variables as shown below
# Set Python 3.5 path
export PATH="/Your Path/.pyenv/versions/3.5.10/bin:$PATH"
# Optionally set PYTHONPATH if you have custom modules
export PYTHONPATH="/path/to/your/python/modules:$PYTHONPATH"
Then finally apply changes by sourcing the file.
source ~/.bashrc
Step 3. Reinstall python and restart MATLAB
If all above steps did not work, I would suggest to reinstalling python and restarting MATLAB to check if it recognises python library

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by