Search code examples
pythongitbashvirtualenvvirtualenvwrapper

Problems with virtualenvwrapper


I've been trying to install virtualenvwrapper/virtualenv. First I have them installed using pip install virtualenv from git bash. For some reason pip saves my files not in /usr/local/bin/virtualenvwrapper.sh but in my Python Scripts folder. Accounting for this I setup my .bashrc as follows:

export WORKON_HOME=$HOME/.virtualenvs
export MSYS_HOME=/c/msys/1.0
source C:/Python27/Scripts/virtualenvwrapper.sh

When I go to setup a virtualenv in gitbash with mkvirtualenv I get the following errors:

virtualenvwrapper.user_scripts could not run "c:\Users\Martin\.virtualenvs\premkvirtualenv": [Error 2] The system cannot find the file specified
virtualenvwrapper.user_scripts could not run "c:\Users\Martin\.virtualenvs\preactivate": [Error 2] The system could not find the file specified 
virtualenvwrapper.user_scripts could not run "c:\Users\Martin\.virtualenvs\test\Scripts\preactivate": [Error 2] The system cannot find the file specified

I looked to see if I have the files and I do. I'm running on Python 2.7.5.


Solution

  • Ok so this was a pain, I found out the hard way that virtualenv doesn't like Windows. Here's how I fixed the problem:

    First I needed to directly download the mktemp.exe for MSYS and place it in the corresponding Git/bin directory, my main problem had to do with GitBash didn't have the MSYSTEM environment set to MINGW32. To make it work in my .bashrc I simply replaced export MSYS_HOME=/c/MinGW/msys/1.0 with export MSYS_HOME=/c/Program\ Files\ \(x86\)/Git or wherever you installed Git.