I'm relatively new to running Python with virtualenv so this might be an easy fix, but I can't for the life of me figure out what's going on. I'm running Windows 7 professional x64 with Python 2.7.5 installed I have installed pip and virtualenv. I have a django project that I'm attempting to work on which I have cloned from a Heroku repository. When I attempt to set up a virtualenv and install the requirements of my project I'm running into a strange error that I can't figure out. I have everything setup as follows:
Django project is placed in C:\Users\xxx\PythonProjects\myProject
I open a command prompt, cd to the myProject folder and execute the following command:
C:\Users\xxx\PythonProjects\myProject> virtualenv --no-site-packages env
This should create a nice clean virtual environment for my project, so I go ahead and activate as follows:
C:\Users\xxx\PythonProjects\myProject> Scripts\activate
The prompt changes to indicate my virtualenv has become active so I double check by "where"ing python and pip:
(env) C:\Users\xxx\PythonProjects\myProject> where python
C:\Users\xxx\PythonProjects\myProject\env\Scripts\python.exe
C:\Python27\python.exe
(env) C:\Users\xxx\PythonProjects\myProject>where pip
C:\Users\xxx\PythonProjects\myProject\env\Scripts\pip.exe
C:\Python27\Scripts\pip.exe
Since it looks like virtualenv is functioning correctly I next attempt to pip the requirements file as follows:
(env) C:\Users\xxx\PythonProjects\myProject> pip install -r requirements.txt
pip appears to run successfully installing all the packages I need. However when I load up python the following happens (django is one of the packages in my requirements file):
(env) C:\Users\xxx\PythonProjects\myProject>python
Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named django
I then cd to the site-packages folder to find out what is going on and get the following:
(env) C:\Users\xxx\PythonProjects\myProject\Lib\site-packages>dir
Volume in drive C is Windows7_OS
Volume Serial Number is 808F-577A
Directory of C:\Users\xxx\PythonProjects\myProject\env\Lib\site-packages
07/17/2013 02:16 PM <DIR> .
07/17/2013 02:16 PM <DIR> ..
07/17/2013 02:16 PM 237 easy-install.pth
07/17/2013 02:16 PM <DIR> pip-1.3.1-py2.7.egg
07/15/2013 09:16 PM 332,005 setuptools-0.6c11-py2.7.egg
07/17/2013 02:16 PM 31 setuptools.pth
3 File(s) 332,273 bytes
3 Dir(s) 169,869,336,576 bytes free
It appears that my pip call failed to install ANYTHING into my site-packages folder, so python has no idea where to find my required packages. Instead they appear to all be located in C:\Users\xxx\PythonProjects\myProject\env\build
If I use pip install foo
without a requirements file, then everything works fine and the foo
ends up in my site-packages folder. Is there a way I can get this working with the requirements file, or am I going to have to manually install every package every time when using virtualenv? Sorry for the likely overly long post, but I wanted to make sure that all relevant information is here. Thanks for the help!
Edit with additional information:
It appears that my requirements file may be the source of the problem. Only about half of the packages are being downloaded, the last being django-polymorphic
. The lines in my requirements file that specify that package and the following package are as follows:
django-polymorphic==0.4.2
-e hg+https://bitbucket.org/fcurella/django-profiles@5c982ce7c040351fca9847a85dd4ff29f8a367e6#egg=django_profiles-dev
django-sekizai==0.7
-e git://github.com/divio/django-shop.git@0fb2258d27332166e3f76ad7cf7335c1f0a389b2#egg=django_shop-dev
-e git://github.com/fivethreeo/django-shop-categories.git@345fb100f5f680e6ac2066f74f25515eb2cd9374#egg=django_shop_categories-dev`
So I figured out the answer to my own question.
Basically, if you are running Python 2.7 (and likely other versions) on Windows, some packages don't play nicely. If anyone else is having this problem, you should download Windows binaries from http://www.lfd.uci.edu/~gohlke/pythonlibs/ and remove those packages from your
requirements.txt
file. Once I did so,pip
stopped crashing during the install process and correctly installed the rest of the packages in myrequirements.txt
file.The packages I needed were: