I would like to avoid backports, they always seem to mess up my packages.

So I was thinking tools like conda / virtualenv / maybe even docker can help. What's the most simple / cleanest way to work with python 3.7 on my system?

  • 1
    Look into pyenv – Naftuli Kay Jul 1 '18 at 21:06

This should get you up and running with Python 3.7 on Ubuntu 16.04

# Install requirements
sudo apt-get install -y build-essential
sudo apt-get install -y checkinstall
sudo apt-get install -y libreadline-gplv2-dev
sudo apt-get install -y libncursesw5-dev
sudo apt-get install -y libssl-dev
sudo apt-get install -y libsqlite3-dev
sudo apt-get install -y tk-dev
sudo apt-get install -y libgdbm-dev
sudo apt-get install -y libc6-dev
sudo apt-get install -y libbz2-dev
sudo apt-get install -y zlib1g-dev
sudo apt-get install -y openssl
sudo apt-get install -y libffi-dev
sudo apt-get install -y python3-dev
sudo apt-get install -y python3-setuptools
sudo apt-get install -y wget

# Prepare to build
mkdir /tmp/Python37
cd /tmp/Python37

# Pull down Python 3.7, build, and install
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
tar xvf Python-3.7.0.tar.xz
cd /tmp/Python37/Python-3.7.0
sudo make altinstall

Then you would just call Python like so:

python3.7 ./yourScript.py

This is a screenshot of multiple versions of Python co-existing in a docker container and how they can be distinguished:

How to call Python different versions

Pip should have been installed with this installation as well. To install packages use this format:

pip3.7 --version

You may wish to wait a couple of weeks/months until Python 3.7 achieves more adoption for library support. Seems like common libraries such as Pillow, Pendulum, Pushbullet, PyPDF2, and Fuzzywuzzy don't yet have compatibility available through pip install and similarly compatible wheels are not yet ready.

  • 1
    This works like a charm. I was able to install python3.7. only caveat is to use sudo make altinstall since the directory access was not to the normal user. all apt-get were installed using sudo as well. Thanks a ton for sharing the info. – Doogle Aug 25 '18 at 12:50
  • The accepted answer worked fine for me, with one caveat; I had to apt install libffi-dev as well to avoid the follwing error in the altinstall step (Ubuntu 16.04 LTS): python ModuleNotFoundError: No module named '_ctypes' – moshisushi Aug 28 '18 at 9:13
  • @moshisushi I ran into that problem as well when I was working towards a resolution. For that reason, I already included libffi-dev in the initial install. – Sn3akyP3t3 Sep 30 '18 at 16:17
  • 1
    @Doogle Prefixed commands with sudo where needed. Thanks for pointing that out. These steps were pulled from my Docker container build steps which assumed root user. – Sn3akyP3t3 Sep 30 '18 at 16:23

You can download the source code from www.python.org, compile and build it from source, and then either:

1) Prepend the path to the python executables to PATH and the libraries to LD_LIBRARY_PATH.

2) Do what I did and compile and build it from source and make symlinks to the executables in /usr/bin. You can call it python37 to distinguish it from the python 3.5 which is already installed.

The first method will use it in your environment by default whereas with the second on, you'll have to specify it with the command you used for the symlink. You might want to use the second method first before you make it the default as python 3.7 is still in development.


I would not recommend manually fiddling around with source code installations and paths. Use pyenv and save yourself the trouble.

All you have to do is:

  • Run the pyenv installer
  • Follow the instructions
  • Install the Python versions you need
  • Choose which Python version you want to use for a given directory, or globally

For example, to install 3.7, check which versions are available:

pyenv install -l | grep 3.7

Then run:

pyenv install 3.7.1

Now, you can choose your Python version:

pyenv global 3.7.1

This switches your python to point to 3.7.1. If you want the system python, run:

pyenv global system

To check which Python versions are available, run pyenv versions.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.