Search code examples
macosbashvirtualenvvirtualenvwrapper

Where did I go wrong in virtualenv installation on OSX?


I followed the instructions carefully at http://jamie.curle.io/blog/installing-pip-virtualenv-and-virtualenvwrapper-on-os-x/

Restarted my terminal and typed mkvirtualenv, got a command not found

looked in /usr/local/bin and ls shows me:

brew                    powerpc-apple-darwin8-gfortran-4.2
charm                   tclsh8.5
django-admin.py             tclsh8.6
django-admin.pyc            virtualenv
gfortran-4.2                virtualenv-2.7
gfortran-uninstall          virtualenv-clone
i686-apple-darwin8-gfortran-4.2     virtualenvwrapper.sh
node                    virtualenvwrapper_lazy.sh
pip                 wish8.5
pip2                    wish8.6

So I know it's in the correct directory. I don't understand where I could have screwed up.


Solution

  • The linked article recommends adding the line source /usr/local/bin/virtualenvwrapper.sh to bash login profile file ~/.bash_login.

    However,

    • ~/.bash_login is rarely used.
    • it is NOT read if the much more common (on OS X) ~/.bash_profile also exists.

    Thus,

    • Check if you have a ~/.bash_profile file
    • and, if so, add the line source /usr/local/bin/virtualenvwrapper.sh there.

    My recommendation is to never use ~/.bash_login. If you find other content, there, also add it to ~/.bash_profile, and delete ~/.bash_login.

    Alternatively, if you're looking for cross-platform compatibility, put all definitions in ~/.bashrc instead, and add only [[ -e ~/.bashrc ]] && . ~/.bashrc to ~/.bash_profile.