简体   繁体   中英

Python 3.9.0 set as default on rasberry pi 4 but my IDE cant see it

I was able to install python 3.9.0 on raspberry 4 and I can verify through the terminal that that has been set as the default python. However, 3 different IDEs (idle, thorny and Microsoft visual code) that I am using cannot find the python 3.9.0 but can see 3.7.3 which came with the pi. I followed this ( link ) instruction but cannot tell why it is not working. I will appreciate any help at all. Thank you.

I'm not sure but for IDLE you may have to install it with

python3.9 -m pip install idle 

or

apt install idle-python3.9 

and you should have to run it as

idle-python3.9

so at the same time you should have

idle-python3.7 

to run it with Python 3.7


thonny (similar to VS Code ) has Tools > Options > Interpreter or Run > Select Interpreter... . You may also use

python3.9 -m pip install thonny 

and it should even use python3.9 to run thonny


You should add Python's folder to existing PATH like

export PATH=/usr/local/opt/python-3.9.0/bin:$PATH. 

As I remeber it has to be splited by : and it has to be = without spaces.

You can check

echo $PATH 

before you set new value to see if it uses : to separate paths.

But usually it should create also links

/usr/bin/python3.7
/usr/bin/python3.9

/usr/bin/pip3.7
/usr/bin/pip3.9

so it should run without any changes in PATH .
At least I have these links on Linux Mint 20 (based on Ubuntu 20.04 ).

You can check if you have

ls -al /usr/bin/python*
ls -al /usr/bin/pip*

and also

which python3.7
which python3.9

which pip3.7
which pip3.9

or

whereis python

whereis pip

or formatted ( new line instead of space )

whereis python | sed 's/ /\n/g'

whereis pip | sed 's/ /\n/g'

Eventually you could create link manually and then you don't have to add folder to PATH

sudo ln -s /usr/local/opt/python-3.9.0/bin/python /usr/bin/python3.9

or you could copy (not move) python to /usr/bin/python3.9

sudo cp /usr/local/opt/python-3.9.0/bin/python /usr/bin/python3.9

Every python version should have own pip to install modules only for this version - they don't share modules.

You have to install pandas in Python 3.9.0 . Check if you have pip3.9

pip3.9 install pandas

or use directly python3.9 like

python3.9 -m pip install pandas

You could check

pip -V 

pip3 -V 

to see for what version they install modules.


BTW:

Stackoverflow has special page for Raspberry Pi

https://raspberrypi.stackexchange.com/

Raspberry Pi has also own official forum

https://www.raspberrypi.org/forums/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM