Last Updated: February 25, 2016
· herchila

Using a virtual environment with Python 3.4

Python 3 and pyvenv

Virtualenv doesn't play nicely with Python 3, so it's best not to try to use it. Virtual environments are now integrated into python 3.4.

Python 3.4's version of pyvenv include pip, making management of virtual environments simple again, and native.

Using pyvenv-3.4

$ pyvenv-3.4 myenv
$ cd myenv
myenv$ source bin/activate
(myenv)$ pip install django

Installing Django (sample)

$ pyvenv-3.4 myenv          # create django virtual env
$ source myenv/bin/activate # activate it
(myenv) $ which pip         # check pip points to the right place
(myenv) $ pip freeze        # check our environment is clean (no output)
(myenv) $ pip install django django-extensions     # install django dependencies
(myenv) $ pip freeze        # see our installed dependencies
(myenv) $ startproject newproject  # create new django project
(myenv) $ pip freeze > newproject/requirements.txt # save dependencies into project


Unfortunately, Ubuntu 14.04 and Debian have a broken pyvenv-3.4 tool.

More info

Quick solution