Question

Would anyone know possible reasons why Django is being installed in the global site package and not my venv's site package folder?

Here's my set up and what I did, this is a bit detailed since I'm new to Python/Django and not sure which information is important:

  1. Python 3.3 is installed in c:\python33
  2. I have virtualenv, pip, easy_install installed in C:\Python33\Scripts.
  3. My venv is c:\users\username\projects\projB
  4. This venv was created using pyvenv, not virtualenv.
  5. I activated the venv.
  6. I changed directory to C:\Python33\Scripts to run "pip install django".
  7. Django was created inside C:\Python33\Lib\site-packages and not inside C:\users\username\projects\projB\Lib\site-packages.

Do I need to install pip inside my venv and use that to install Django?

Was it helpful?

Solution 2

Pip should be installed when you create the virtual environment. Don't change directory into C:\Python33\Scripts before running pip. It looks like that means you use the base install's pip instead of your virtual environment's pip.

You should be able to run pip from any other directory. However I'm not familiar with python on Windows, so I'm not certain that pip is added to the path when you activate the environment. If that doesn't work, you'll have to change directory into the bin directory of your virtual environment, then run pip.

OTHER TIPS

You can specify in your virutalenv wich python version you whant:

$ virtualenv -p <PATH TO PYTHON VERSION> my_virtualenv

Then:

$ source my_virtualenv/bin/activate
$ pip install Django==1.5.2

This will install the good version of django in your virtualenv according to your python version.

Thanks to virtualanv, you will be able to save/freeze and install your environement on another machine:

$ pip freeze > requirement.txt
$ pip install -r requirement.txt

You will see in the requirement.txt file the django dependency.

What happened to me was that I was trying to install django from outside the environment directory/folder.
So make sure you are inside the environment directory and then use pip install django

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top