Skip to content

Instantly share code, notes, and snippets.

Last active November 9, 2021 19:38
What would you like to do?
Ubuntu 14.04 Python 3.4.2 Setup using pyenv and pyvenv

What I did to get Python 3.4.2 on Ubuntu 14.04. The stock version of Python 3 on Ubuntu is 3.4.0. Which is missing some of the best parts! (asyncio, etc). Luckily I discovered pyenv which solved my problem.

Install pyenv

Pyenv (not to be confused with pyvenv) is the Python equivelant of rbenv. It lets you configure which Python environment/version is available per directory, user, or other session variables.

I followed the instructions here to install pyenv in my home directory. Verbatem, those instructions are:

sudo apt-get install git python-pip make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev
sudo pip install virtualenvwrapper

git clone ~/.pyenv
git clone ~/.pyenv/plugins/pyenv-virtualenvwrapper

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
echo 'pyenv virtualenvwrapper' >> ~/.bashrc

Install Python 3.4.2

Restart your shell to pickup pyenv. Then tell pyenv to download, build, and instatll 3.4.2:

pyenv install 3.4.2

Point a project at 3.4.2

Place a hidden file .python-version in your project. In this file simply place the text:


In this directory, type python to enter the shell and note the version. It should be 3.4.2.


You should also now be able to use pyvenv to bootstrap a virtual environment in this directory. It will bootstrap a virtualenv with python 3.4.2 as the python version. You can do everything you'd normally do in a virtualenv, like install dependencies, etc:

pyvenv venv
source venv/bin/activate
pip install requests
pip freeze > requirements.txt


I use pyflakes with Syntastic for finding syntax bugs in VIM. I had to be sure to install pyflakes to python 3.4.2 by going into a directory where 3.4.2 was being used and doing

pip install pyflakes
Copy link

Bakley commented Feb 4, 2016

No command 'pyenv' found, did you mean:
Command 'p7env' from package 'libnss3-tools' (main)
pyenv: command not found
No command 'pyenv' found, did you mean:
Command 'p7env' from package 'libnss3-tools' (main)
pyenv: command not found

this is what i am getting

Copy link

@Bakley, you may need to reload your environment file so that the command is recognized. Try running
source .bashrc or source .zshrc to see if the command registers. You can also run eval "$(pyenv init -)"
manually if you need to.

Copy link

ejmg commented Dec 26, 2016

Fantastic! Thank you, this small little guide cleared up a lot of my confusion. You should consider opening up a page in the pyenv repo to add this tutorial. I'm a bit confused as to why the author has put so little documentation on what is clearly a really great package.

Copy link

ghost commented Feb 17, 2017

@regiellis I tried the commands you mentioned but am still getting the same problems as Bakley. Any suggestions?

Copy link

Don't forget to source ~/.bashrc if you don't reopen the terminal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment