zhiqiang huang
zhiqiang huang

Reputation: 361

There is something wrong with virtualenvwrapper setting

I have installed python2 and python3 in my Mac osx and currently I'm using python3. And I am able to pip3 install virtualenv and virtualenvwrapper. The problem is whenever I restart my terminal, the settings for virtualenvwrapper don't work, like I can't use the commands mkvirtualenv and workon. The error I get is bash: the command workon is not found. I think there must be something wrong with my settings about the virtualenvwrapper. Here is what I try:

All my virtualenv packages are installed in the ~/Envs and after that, I source the .bashrc and it works, I could use workon and mkvirtualenv but once I reopen a new terminal it still could find't the workon command. Does anyone know what's wrong with my setting?

Upvotes: 0

Views: 284

Answers (2)

zhiqiang huang
zhiqiang huang

Reputation: 361

After a few try, finally it works. There are two problems. The first one is because I have both python2 and python3 installed in my machine and by default the virtualenvwrapper try to run using the default python(in /usr/bin/python which is python2) so I have to change it to point to python3. So in my .bashrc file:

export WORKON_HOME=~/Envs 
export VIRTUALENVWRAPPER_PYTHON=PATHS/TO/PYTHON3
source ~/Envs/django_projects/bin/virtualenvwrapper.sh

The second one is that .bashrc doesn't run automatically,we have to source in to ./bash_profile. Check https://apple.stackexchange.com/questions/12993/why-doesnt-bashrc-run-automatically for detail.

Then reopen the terminal and ta-da.

Upvotes: 1

mic4ael
mic4ael

Reputation: 8310

In order to be able to use virtualenvwrapper you need to source the script that is somewhere in /Users/mic4ael/Library/Python/{Python version}/bin/virtualenvwrapper.sh. So you could put source /Users/mic4ael/Library/Python/{Python version}/bin/virtualenvwrapper.sh to your .bashrc to make it every time you launch a terminal.

Upvotes: 0

Related Questions