How do I upgrade my python installation, and pip?
On my Ubuntu server, Python 3.8 and 2-something is installed.
I want to upgrade to Python 3.10, and I installed it from a ppa. But 3.8 is still installed, and pip --version
shows pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
I tried running a script with this command: python3.10 myscript.py
but this fails because this script is using the websockets
package. If I run pip install websockets
it says that it is already installed. But it isn't installed for Python 3.10, only 3.8.
So in short: How do I upgrade to Python and pip to version 3.10?
EDIT: these are the commands I used to upgrade Python to 3.10
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.10
There is two options
-
Changing ubuntu's python3:
sudo mv /usr/bin/python3 /usr/bin/python3_backup & sudo ln -s /usr/bin/python3.10 /usr/bin/python3
-
Creating a virtualenv and use that env
python3.10 -m venv venv_folder source venv_folder/bin/activate pip .. python ..
After finished your job with this env, you can just type deactivate
and venv will close.
Second method is a workaround solution.