22

I created two virtualenv and I installed two different versions of django. Now I have a problem to activate the two environment, I do like this :

source Django1.6/bin/activate

Then I see that the environment was activated. Then I do :

pip install django # for test

and I get this message :

Requirement already satisfied (use --upgrade to upgrade): 
                                 django in /usr/local/lib/python2.7/dist-packages

This tell that the environment was not activated but it use the default one. Why I'm getting this?

Hunsu
  • 3,281
  • 7
  • 29
  • 64
  • 2
    The message mentions `/usr/local/lib/python2.7` so it might be the case that you have Django installed system-wide. Could you check this? – Greg Navis Sep 20 '16 at 12:18

2 Answers2

39

When changing the environment location we must execute virtualenv on the new folder. When looking to activate file I have found this code :

VIRTUAL_ENV="/old/folder"
export VIRTUAL_ENV

This variable will updated when we execute virtualenv on the new folder.

Hunsu
  • 3,281
  • 7
  • 29
  • 64
20

Lets say you have got two virtual environments installed venv1 and venv2.

virtualenv venv1
virtualenv venv2

Virtualenv will create the directories and install the relevant Python libraries, PIP, etc.

Activate each environment one at a time.do your stuff and deactivate.

source venv1/bin/activate    
# make changes to the environment. i.e pip install django==1.6.8
deactivate

source venv2/bin/activate   
# make changes to the environment. i.e pip install django==1.7.1
deactivate

can check installed django versions.

source venv1/bin/activate
python
import django
django.VERSION
[. . . . make note of the version of django running . . . .]
deactivate

source venv2/bin/activate
python
import django
django.VERSION
[. . . . make note of the version of django running . . . .]
deactivate

If everything was done correctly you should see a different version of Django running in each virtualenv.

NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104
Siyaram Malav
  • 4,414
  • 2
  • 31
  • 31