Install Python 3.7 with Pyenv on Debian 9

I decided to upgrade my development VM from Debian 8 to Debian 9. Although I had wanted to do this for quite some time, I took the plunge after I bagged a whooping 40GB of bonus data from MTN…and couldn’t get libssl1.0.2+ to install on debian 8.

I have been a fan of pyenv since I moved to Debian from Windows. So after several SO entries and websites, find how to install python 3.7 with pyenv on debian 9 below.

First, install pyenv using the pyenv-installer (https://github.com/pyenv/pyenv-installer). It’s the fastest way to install pyenv IMO. You’ll need to update your bashrc file at the end of the installation, so you can do “pyenv …” in CLI.

Then install the dependencies for python 3.7

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get install build-essential checkinstall python-dev python-setuptools python-pip python-smbus
sudo apt-get install libncursesw5-dev libgdbm-dev libc6-dev
sudo apt-get install zlib1g-dev libsqlite3-dev tk-dev
sudo apt-get install libssl-dev openssl
sudo apt-get install libffi-dev

Finally, run pyenv install 3.7.0

After about 10 minutes, you should have Python 3.7.0 installed in pyenv.

To make this version of python the default system-wide version, run pyenv global 3.7.0

Leave a Reply