14

I can create a new virtualenv that ignores global site-packages with "--no-site-package". Is it possible to change an existing virtualenv (which was created without "--no-site-package") to also ignore the global site-packages? (So that it workes like it was created with "--no-site-package" in the first place.)

thanks in advance,

Sebastian

Sebastian
  • 141
  • 1
  • 3

2 Answers2

20

I think all you have to do is create an empty file called no-global-site-packages.txt and put it into the virtualenv's python2.x folder (eg, lib/python2.6/, the one with all the modules). Then the normal site.py generated by virtualenv detects the difference and handles everything from there.

ianmclaury
  • 1,156
  • 6
  • 5
  • 1
    Thank you, that pointed me in the right direction. The file has to be in the lib/pythonX.Y/ directory (inside the virtualenv-directory), not in site-packages, though. – Sebastian Oct 07 '10 at 10:22
9

Can you just create a new one and then re-create it with the --no-site-package? If you use pip then you can use pip freeze > requirements.pip to generate a requirements file to re-install into your new virtualenv.

JudoWill
  • 4,741
  • 2
  • 36
  • 48
  • Can't thank you enough for this suggestion; have wasted hours because stupid Conda messed up my system. Thanks! :) – Shatu May 26 '17 at 00:20