Tested on:RPi3; Raspbian Stretch
Prerequisites:Raspberry Pi with Raspbian Jessie and internet connection (see steps 1-7 in the Introduction)

Pyenv for Python version management on Raspbian Stretch

Using different versions of Python on a single machine causes complications frequently, for example by missing dependencies. PyEnv is a promising solution to this problems since it allows installing and keeping different Python versions including dependencies and managing virtual environments.

Enter in the terminal

Enter the following for installing a specific Python version:

The installation takes a while. Now, show all installed versions by entering

A specific Python version can be linked to a directory:

Output: Python 3.6.3
After leaving the directory, the system wide Python version is active again.

Output: Python 2.7.13
The following command sets the Python version for the whole system:

GitHub PyEnv: https://github.com/pyenv/pyenv

Knight of Pi

Johannes Bergs aka Knight of Pi. Diploma in Bioinformatics, some Webdesign and Python coding then. Living in the beautiful city of Vienna.


  1. you might want to put

    git clone git://github.com/yyuu/pyenv.git ~/.pyenv

    in there instead, in case people run this outside their home directories.

  2. Maybe say that git must be installed… :)
    sudo apt-get install git

  3. Finally, a way that works. Thank you so so much!
    Just for reference: I swapped the numbers to 3.7.2 and it worked perfectly. Took about two hours on a Pi Zero W.

    Thanks, man.


Time limit is exhausted. Please reload CAPTCHA.