python3.5 library does not show in pyversion

조회 수: 1 (최근 30일)
Willy Bernal
Willy Bernal 2021년 2월 7일
답변: Rushikesh 2024년 8월 9일
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

답변 (1개)

Rushikesh
Rushikesh 2024년 8월 9일
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

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by