Question

I am trying to install and use pyenv-virtualenvwrapper to create a virtual python environment. I am on ubuntu 13.04.

$ pyenv version
2.7.5 (set by /home/evan/.pyenv/version)

$ pip freeze | grep virtual
virtualenv==1.10.1
virtualenv-clone==0.2.4
virtualenvwrapper==4.1.1

$ ls ~/.pyenv/plugins/
pyenv-virtualenvwrapper python-build version-ext-compat

$ pyenv virtualenvwrapper
virtualenvwrapper not installed.

$pyenv which virtualenvwrapper.sh
pyenv: virtualenvwrapper.sh: command not found

$ pyenv whence virtualenvwrapper.sh
$

$ which $HOME/.pyenv/shims/pip
/home/evan/.pyenv/shims/pip

Has anyone else worked their way through this issue? I would like to create a virtual environment. In pythonbrew which I used in prior versions of ubuntu, I would have just..

$ mkvirtualenv dssg
$ workon dssg
(dssg) $ 

Here:

$ mkvirtualenv dssg
mkvirtualenv: command not found
$ pyenv mkvirtualenv
mkvirtualenv: no such command `mkvirtualenv'
$ pyenv virtualenvwrapper mkvirtualenv
virtualenvwrapper not installed.
$ 
Was it helpful?

Solution

In order to create a virtual environment in a non-system (virtual) version of python under the control pyenv, you need to use a slightly different syntax. From the documentation of virtualenv plugin

$ pyenv virtualenv venv33

For me this only works if I am in the directory of the non-system version of python ~/.pyenv/versions/2.7.5. I have a tutorial that walks you through this at http://mofj.commons.gc.cuny.edu/2014/01/20/ubuntu-set-up-a-virtual-environment-with-ipython-numpy-and-pandas/

OTHER TIPS

This is actually something really silly an unintuitive about how virtualenvwrapper works on Ubuntu. On most operating systems the following command will let you source virtualenvwrapper.sh:

source `which virtualenvwrapper.sh`

However, for some strange reason, it is instead stored in /etc/bash_completion.d/virtualenvwrapper

So if you want access to the mkvirtualenv command you need to source it in the following way:

source /etc/bash_completion.d/virtualanevwrapper

Depending on how often you make virtualenvs it might be worth making an alias for that just because it's unintuitive, but I usually don't use this enough that it's worth it.

In the future if you're trying to locate something you should read up on the find and locate functions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top