how do I let matlab use a specific python3 version?

4 次查看(过去 30 天)
I am running Ubuntu 18 and Matlab R2022b. My Ubuntu does not like to have a different default python3 than python3.6 (it then gives all kind of weird errors like not being able to start a terminal). Matlab R2022b does not support python3.6. I have python3.8 installed via deadsnakes/sudo apt-get install python3.8 and it works fine in the terminal (/usr/bin/python3.8). When I set this in Matlab via pyversion('/usr/bin/python3.8') it does not work. Any hints?
when I run pyversion I get:
pyversion
version: '3.8'
executable: '/usr/bin/python3.8'
library: ''
home: '/usr'
isloaded: 0
so library remains empty.
then when I run:
py.list({'This','is a','list'})
Unable to resolve the name 'py.list'.
Running pyversion('/usr/bin/python3') obviously gives the error 'Python version 3.6 is not supported.'
Running pyversion('/usr/bin/python2.7') results in a working environment:
pyversion
version: '2.7'
executable: '/usr/bin/python2.7'
library: 'libpython2.7.so.1.0'
home: '/usr'
isloaded: 0
but I need python3 instead! Any help?

采纳的回答

Sven
Sven 2023-3-27
I managed to solve it by installing the -dev version of python3.8:
sudo apt-get install python3.8-dev

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Call Python from MATLAB 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by