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?
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?
It would be wise to use pyenv to safely manage multiple versions of Python installed on the same system.
Nonetheless, this should get you up and running with Python 3.7.10 on Ubuntu 16.04
# WARNING: As of April 30th 2021, Ubuntu Linux 16.04 LTS will no longer supported
# NOTE: It appears that Python 3.7.* has arrived into maintenance mode and will likely
# only be getting security updates. See release notes https://www.python.org/downloads/release/python-3710/
# Install requirements
sudo apt-get install -y build-essential \
checkinstall \
libreadline-gplv2-dev \
libncursesw5-dev \
libssl-dev \
libsqlite3-dev \
tk-dev \
libgdbm-dev \
libc6-dev \
libbz2-dev \
zlib1g-dev \
openssl \
libffi-dev \
python3-dev \
python3-setuptools \
wget
# Prepare to build
mkdir /tmp/Python37
mkdir /tmp/Python37/Python-3.7.10
cd /tmp/Python37/
# Pull down Python 3.7.10, build, and install
wget https://www.python.org/ftp/python/3.7.10/Python-3.7.10.tar.xz
tar xvf Python-3.7.10.tar.xz -C /tmp/Python37
cd /tmp/Python37/Python-3.7.10/
./configure --enable-optimizations
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:
Pip should have been installed with this installation as well. To install packages use this format:
pip3.7 -V
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:
pyenv
installerFor 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
.
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.