python3.5 library does not show in pyversion
조회 수: 1 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
Rushikesh
2024년 8월 9일
Hello @Willy Bernal
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
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!