0

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:

  • edit the ~/.bashrc:

    export WORKON_HOME=~/Envs
    
  • source ~/Envs/django_projects/bin/virtualenvwrapper.sh

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?

2
  • that's a typo, I changed it now. Commented Apr 11, 2017 at 20:48
  • Reopened and removed comment. Thanks for following up.
    – tripleee
    Commented Apr 11, 2017 at 20:49

2 Answers 2

1

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.

0

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.

1
  • try your solution and end up another error saying that the hook is loading,make sure python is under /usr/bin/python,because I have both python2 and python3 installed and python2's path is /usr/bin/python and python3's path is /Libray/bin/python, so I don't know how to fix that to let the virtualenvwrapper to point to python3 instead of python2. Commented Apr 11, 2017 at 20:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.