52

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.

3
  • 3
    Shouldn't this question be posted on askubuntu.com ? Commented Jul 11, 2018 at 8:24
  • 2
    @mahir: … possibly. Even though "Python" falls under SO's missives, the question is not about Python. It appears to me OP simply does not know what to do with a tar file, which falls under "general computing". Commented Jul 11, 2018 at 8:42
  • 1
    See How do I install the latest Python 2.7.X or 3.X on Ubuntu? over on Ask Ubuntu. Commented Feb 16, 2019 at 16:25

2 Answers 2

63

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/

Sign up to request clarification or add additional context in comments.

16 Comments

I tested it and it worked
I tested it and it didn't work because it lacked the PPA...
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.
This worked for me on Ubuntu 18.04!
whypython3-dev and not python3.7-dev?
|
23

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

5 Comments

Thanks, I have seen this answer in askubuntu. But is there an official way by Python official..?
I'd go with the PPA, but I edited my post for an official way using the code from the site.
I tried the official way, until failed in the make install..
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
Im sorry, I cant really help you with ´make install´ problems, I`d suggest using the PPA.