virtualenvwrapper-win "No module named pip"
9/Sep 2015
If you use virtualenvwrapper on Windows, you may have come across an issue where the environment cannot be created properly due to “ImportError: No module named pip”
I’ll let you Google the reason; here’s a fix. Basically, you need to create the environment without setuptools
. Here are the basic steps:
mkvirtualenv --no-setuptools --no-site-packages newenv
wget --no-check-cert https://raw.github.com/pypa/pip/master/contrib/get-pip.py
python get-pip.py
del get-pip.py
Because I do this every so often, I’ve implemented my own mkvirtualenv
batch file like so:
@echo off
IF .%1 == . (
echo Usage: mkvirtualenv 'env name'
GOTO :eof
)
@echo on
call C:\Python27\Scripts\mkvirtualenv.bat --no-setuptools --no-site-packages %1
wget --no-check-cert https://raw.github.com/pypa/pip/master/contrib/get-pip.py
python get-pip.py
del get-pip.py
FYI: I store batch files like this in C:\bin
. I then put C:\bin
in my path, so they’re available to all of my command-line activities.
The batch file is not perfect, since the path to the actual mkvirtualenv
is hard coded, but it’s far easier than trying to store the output of something like python -c "import os,sys; print os.path.join(os.path.dirname(sys.executable), 'Scripts', 'mkvirtualenv.bat')"
.