How to upgrade Python version to 3.7?

150,629

Solution 1

Try this if you are on ubuntu:

sudo apt-get update
sudo apt-get install build-essential libpq-dev libssl-dev openssl libffi-dev zlib1g-dev
sudo apt-get install python3-pip python3.7-dev
sudo apt-get install python3.7

In case you don't have the repository and so it fires a not-found package you first have to install this:

sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update

more info here: http://devopspy.com/python/install-python-3-6-ubuntu-lts/

Solution 2

On ubuntu you can add this PPA Repository and use it to install python 3.7: https://launchpad.net/~jonathonf/+archive/ubuntu/python-3.7

Or a different PPA that provides several Python versions is Deadsnakes: https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa

See also here: https://askubuntu.com/questions/865554/how-do-i-install-python-3-6-using-apt-get (I know it says 3.6 in the url, but the deadsnakes ppa also contains 3.7 so you can use it for 3.7 just the same)

If you want "official" you'd have to install it from the sources from the site, get the code (which you already downloaded) and do this:

tar -xf Python-3.7.0.tar.xz
cd Python-3.7.0
./configure
make
sudo make install        <-- sudo is required.

This might take a while

Share:
150,629
Admin
Author by

Admin

Updated on June 15, 2020

Comments

  • Admin
    Admin almost 4 years

    I have python3.5 already in linux ubuntu. I have downloaded the python3.7.tar www.python.org.

    But i have no idea how to install it. How to upgrade to python 3.7? Thanks.

  • Bernhard
    Bernhard almost 6 years
    I don't think that'll work with 3.7 since it's not yet in the main repositories.
  • jc1850
    jc1850 almost 6 years
    I tested it and it worked
  • Admin
    Admin almost 6 years
    Thanks, I have seen this answer in askubuntu. But is there an official way by Python official..?
  • Bernhard
    Bernhard almost 6 years
    I'd go with the PPA, but I edited my post for an official way using the code from the site.
  • Admin
    Admin almost 6 years
    I tried the official way, until failed in the make install..
  • Hadrien TOMA
    Hadrien TOMA almost 6 years
    I tested it and it didn't work because it lacked the PPA...
  • Christopher Hunter
    Christopher Hunter over 5 years
    does not work on 14.04 for python3.7. there are no packages for trusty.
  • manneym
    manneym over 5 years
    Tested on Ubuntu 16.04.5 LTS. Not working. Please update answer with PPA instructions.
  • Diego Rodríguez
    Diego Rodríguez over 5 years
    I just installed python 3.7 in Ubuntu 16.04 using the above instructions and using the Deadsnakes PPA . To add the PPA just execute sudo add-apt-repository ppa:deadsnakes/ppa and sudo apt-get update.
  • dabadaba
    dabadaba over 5 years
    I tried this but it also failed when running make install. I read the docs and it said that if the system already had Python preinstalled (which mine does as Python 3.6.6) you should run make altinstall instead. But I got the exact same error
  • Bernhard
    Bernhard over 5 years
    Im sorry, I cant really help you with ´make install´ problems, I`d suggest using the PPA.
  • Dan
    Dan over 5 years
    This worked for me on Ubuntu 18.04!
  • Kalob Taulien
    Kalob Taulien over 5 years
    Confirmed to work on Ubuntu 18.04. No additional PPA required (Jan 2019)
  • Kwame
    Kwame over 5 years
    Confirmed to require ppa on Ubuntu 18.04
  • dangel
    dangel about 5 years
    whypython3-dev and not python3.7-dev?
  • Pynchia
    Pynchia about 5 years
    It worked for me (the last step sudo apt-get install python3.7 did nothing as satisfied already) but just a note: you will still have to update the symbolic links manually if you want 3.7 to be the one that pops up when calling python or python3
  • Pynchia
    Pynchia about 5 years
    furthermore: in case you cannot create a venv anymore and sudo apt-get install python3-venv fails, do sudo apt-get install python3.7-venv instead
  • dangel
    dangel about 5 years
    some caution about making python3.7 the default, I've had some serious issues when doing this later down the road when updating other software. I'm sure I did something wrong, but still
  • tnusraddinov
    tnusraddinov over 4 years
    Add python3.7 to update-alternatives sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 2 Update python3 to point to python3.7 sudo update-alternatives --config python3 Enter number for python3.7 python3 -V jcutrer.com/linux/upgrade-python37-ubuntu1810
  • Anthony
    Anthony almost 3 years
    Doesn't worksasd