12

I am tried by this command

sudo pip3 install --upgrade python

but still, it did not work.

peterh
  • 11,875
  • 18
  • 85
  • 108
Shiva_Adasule
  • 769
  • 2
  • 9
  • 14

3 Answers3

21

Try this:

sudo apt-get update

sudo apt-get install python3.8

And if you want to replace the 3.7 with 3.8 for the python3 on your computer use the following after running the above commands.

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2

You can switch between python versions on your computer by running the following command. This will show you the installed versions and you can select which one you want to use.

sudo update-alternatives --config python3
Yepram Yeransian
  • 321
  • 1
  • 14
  • But I can't use my previously installed libraries in python3.8 – Shiva_Adasule Nov 23 '19 at 04:54
  • 2
    @Shiva_Adasule, Yes. You are correct. When you upgrade your your Python version, you will need to also reinstall any libraris you use at the SYSTEM level. The correct way to manage this for individual projects is to use virtualenvs where both the version of python and the libraries are maintained for that specific project\application. Lots about that online. – Patrick Feb 05 '20 at 20:00
18

pip is not capable of upgrading python - it is for python packages. Use,

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.8

On Ubuntu. You may also want -dev and -venv:

sudo apt-get install python3.8-venv python3.8-dev

To ensure you have 3.8 pip, virtualenv, and such.

modesitt
  • 7,052
  • 2
  • 34
  • 64
  • To install python on Ubuntu 14.04. You may not be able to install python3.8. Which python version you can install you can check with `apt-cache search python3.7`. If prompt returns without output, python3.7 can not be installed, try installing a lower version of python. – Pradeep Singh May 11 '20 at 17:56
1

Try this

sudo apt --fix-missing purge $(dpkg -l | grep 'python3\.7' | awk '{print $2}')

then run

sudo apt upgrade