3

I have a problem because I have some python installions inside a virtualenv and some oustide.

Take for example Django-crispy-forms. Its current version is 1.5.1, but I want my old site (outside the virtualenv) to keep 1.4.0 and my new site (inside the virtualenv) should have the latest version.

I thought that source bin/activate and then pip install django-crispy-forms would help, but it complains that it is already there (outside the virtualenv). This I can understand, and it takes the ones outside the virtualenv.

But now I want to upgrade inside my virtualenv, using pip install --upgrade django-crispy-forms.

Collecting django-crispy-forms

Downloading django-crispy-forms-1.5.2.tar.gz (114kB)

100% |████████████████████████████████| 114kB 3.9MB/s 

Building wheels for collected packages: django-crispy-forms
  Running setup.py bdist_wheel for django-crispy-forms
  Stored in directory:   /home/gabn88/.cache/pip/wheels/35/c8/45/4c3e856aed73cfdf2ff25e600d95bdd20eba71b3d3cca38cb2
Successfully built django-crispy-forms
Installing collected packages: django-crispy-forms
  Found existing installation: django-crispy-forms 1.4.0
    Not uninstalling django-crispy-forms at /lib/python3.4, outside  environment /webapps/production_v3
Successfully installed django-crispy-forms-1.4.0

As you can see it did not update.

Extra info: The packages it uses are installed outside the virtualenv by pip install --user.... Maybe that helps finding a solution, thank you!

Dušan Maďar
  • 9,269
  • 5
  • 49
  • 64
gabn88
  • 781
  • 8
  • 23
  • 1
    Have you tried specifying a version number? Something like `pip install -I django-crispy-forms==1.5.2`? – wpercy Dec 15 '15 at 14:58
  • I also tried that, didn't work. Same output. – gabn88 Dec 15 '15 at 15:05
  • Oh, wait! I now see that it did install into the virtualenv/lib/python3.4/site-packages/crispy_forms folder, but it still uses the one from /lib/python3.4/crispy_forms (not the virtualenv). However I still don't know how to solve this... I thought the virtualenv always uses the packages inside the virtualenv first! – gabn88 Dec 15 '15 at 15:10
  • 1
    I think this is because of the *order* of the paths - that your system is above the virtual env. Have a look at this: http://stackoverflow.com/questions/28239484/sorting-sys-path-first-virtualenv-then-usr Basically, have a look at your `sys.path` and the order. I understand that it uses first-found-lib, so the order is important. What you might want to do is make a new virtual env which doesn't inherit system packages, and then add the system packages to it using add2virtualenv. – Jmons Dec 15 '15 at 15:18
  • Thanks for the information! If I look into myvirtualenv/python3.4/site.py I see that it imports USERSITE, how can I set ENABLE_USER_SITE to false for the virtualenv only? – gabn88 Dec 15 '15 at 15:33
  • Ah, wait. It seems to be USER_BASE what I've been searching for... How to disable this? – gabn88 Dec 15 '15 at 15:46
  • Oh, no. It is the user_script folder... https://www.python.org/dev/peps/pep-0370/ That still leaves the question how to disable this open... – gabn88 Dec 15 '15 at 15:52
  • python -S (note the capital) seems to work, but breaks all normal things like exit(). Then I have to use sys.exit(), which I don't like as well :( – gabn88 Dec 15 '15 at 15:58

0 Answers0