Skip to content

Python versions

list installed python versions

`ls -ls /usr/bin/python*``
/usr/bin/python3 -> python3.8
==/usr/bin/python3.8==
/usr/bin/python3.8-config -> x86_64-linux-gnu-python3.8-config
==/usr/bin/python3.9==
/usr/bin/python3-config -> python3.8-config
/usr/bin/python3-futurize
/usr/bin/python3-pasteurize
/usr/bin/python3-qr
/usr/bin/python3-wsdump

python3 --version
==> Python 3.8.10

pip -V
==> pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

andere tools , libraries , wrappers GUI , etc

python & visual studio code

if more then 1 python interpreter is installed then dependencies can be different , and also packages & pip installations
therefore , sometimes code does not run on 1 version , but it does on another
to force visual studio code to use a specifiek interpreter :

type ctrl + p
and then type >Python: Select Interpreter  (auto fill will kick in )
(don’t forget the > character! if it doesn’t show up, make sure you have installed python extension on your vs code) and select one of the options.
It will show you available interpreters (virtual environments + the global environment) to choose.

![[Pasted image 20220907112456.png]]

If you want to change version of python you are using, you must first create a virtual environment with desired version of python and then choose it as your interpreter. (I recommend to create it in .venv directory in the root directory of your project)
This answer will help you with that.

side-by-side multiple versions

/usr/bin on 2023-08 :
2.7
3.8
3.9

3.8 is default ( and os version python)

force a python version : prefix command with the correct python version (major.minor without build verson)
python3.9 {command or script}
see for a nice example obsidian create a website which required python3.9

there is a python.2 script ‘pyversions’ but that fails to execute
update : Get sversions of imported modules in current session

![[Pasted image 20230818103433.png]]