0

A few months ago I installed virtualenv, virtualenvwrapper and pip, created a few virtual environments and played with Django successfully.

After returning to my projects today, I am unable to use any of these commands. For instance:

/> lsvirtualenv

returns:

/ >

Further:

/ > workon

also returns:

/ >

What might be the reason for this? Folder .virtualenv is located here /users/myUser/documents/projects/.virtualenvs and its contents are:

get_env_details
postactivate
postmkproject
postrmvirtualenv
predeactivate
premkvirtualenv
initialize
postdeactivate
postmkvirtualenv
preactivate
premkproject
prermvirtualenv

What am I missing? Thanks!

Alexander Starbuck
  • 1,139
  • 4
  • 18
  • 31

1 Answers1

0

These commands are generated by the script virtualenvwrapper.sh. You have to source that file in order to get the commands.

Try this:

find / -name "virtualenvwrapper.sh" 2>/dev/null

It should find and return the filepath. On my system it is:

/usr/share/virtualenvwrapper/virtualenvwrapper.sh

So you can do:

source /usr/share/virtualenvwrapper/virtualenvwrapper.sh

Now you should have the commands. Probably you'd like to have these commands without sourcing virtualenvwrapper.sh everytime you boot your system.

Add that line to your .bashrc (or alternatively in .bash_profile or .profile), along with two other lines

export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Projects
source /usr/share/virtualenvwrapper/virtualenvwrapper.sh

After that create the directory Projects (you can call it whatever you want and place it whereever you want) manually:

mkdir $HOME/Projects

After the next start you should have all the commands and the new environment variables. When you do:

mkproject foo

new directory foo will be created:

.virtualenvs/foo

and:

Projects/foo

The first one is your virtual environment, the second one is where your projects lives. With workon foo you can activate it, and with cdvirtualenv and cdproject you can switch between them.

EDIT:

After rereading your question, I think the problem might be eventually with the way how you created the virtual environments.

The commands lsvirtualenv and workon are provided by virtualenvwrapper. If you create your virtual environments with the comand mkvirtualenv (also provided by virtualenvwrapper) then lsvirtualenv and workon will list them.

But if you create them like this:

virtualenv foo

virtualenvwrapper won't be aware of your virtual environments.

cezar
  • 11,616
  • 6
  • 48
  • 84