wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
tar xvf Python-3.6.3.tgz
cd Python-3.6.3
./configure --enable-optimizations
make -j8
sudo make altinstall
python3.6
It is recommended to use make altinstall
according to the official website.
Warning:
make install
can overwrite or masquerade the python binary.make altinstall
is therefore recommended instead ofmake install
since it only installsexec_prefix/bin/pythonversion
.
Some package need to be installed to avoid some known problems
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev
sudo apt-get install -y libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm
sudo apt-get install -y libncurses5-dev libncursesw5-dev xz-utils tk-dev
The official recommendation is "you don't actually need newer software"
https://wiki.debian.org/DontBreakDebian#Don.27t_suffer_from_Shiny_New_Stuff_Syndrome
Most of the advice on that page is geared towards what to do if you want the software to be available system-wide, but I don't think that's necessary in this case.
If you fetch the python sources, build the 3.6 interpreter using --prefix
to control where it ends up, and then use virtualenv
with the --python
option, then you can use python 3.6 without affecting anything outside your project.
The process might go something like this:
$ cd ~
$ mkdir pythonroot
$ mkdir opt
$ mkdir app
$ cd opt
$ wget <python tarball>
$ tar -xvf <python tarball>
$ cd python-3.6
$ ./configure --prefix="$HOME"/pythonroot
$ make
$ make install
$ cd ~
$ cd app
$ virtualenv venv --python ~/pythonroot/bin/python
$ . venv/bin/activate
[venv]$ which python
/home/<user>/pythonroot/bin/python
https://unix.stackexchange.com/questions/332641/how-to-install-python-3-6