Setting up pyenv on Ubuntu 16.04: The missing steps from the other guides

Published by moxlotus on

Installing pyenv is rather straight forward, one simply has to run the command below

curl -L | bash

And when you tried to install a python version, you will probably see the follow error or something similar.

$ pyenv install 3.6.3
Downloading Python-3.6.3.tar.xz...
Installing Python-3.6.3...
BUILD FAILED (Ubuntu 16.04 using python-build 20160602)
Inspect or clean up the working tree at /tmp/python-build.20180218111837.1471
Results logged to /tmp/python-build.20180218111837.1471.log
Last 10 log lines:
checking for --with-universal-archs... no
checking MACHDEP... linux
checking for --without-gcc... no
checking for --with-icc... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/tmp/python-build.20180218111837.1471/Python-3.6.3':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

Yes, we have missing packages that needs to be installed before we can install any python. Run the following command before you install pyenv.

sudo apt-get install build-essential git libreadline-dev zlib1g-dev libssl-dev libbz2-dev libsqlite3-dev

This will install all the packages that is needed to build and install the particular python version.

Try installing again, and you will not see anymore errors.

$ pyenv install 3.6.4
 Downloading Python-3.6.4.tar.xz...
 Installing Python-3.6.4...
 Installed Python-3.6.4 to /home/moxlotus/.pyenv/versions/3.6.4
Share it with others
Categories: Ubuntu