18

is it possible to nest 2 virtualenvs?

I would like to have a base virtualenv and then a more specific virtualenv that accesses all the packages from the base virtualenv and then has its own.

Any hint appreciated, thanks.

Andrea Zonca
  • 8,378
  • 9
  • 42
  • 70
  • 1
    I just found this answer, http://stackoverflow.com/questions/10538675/can-a-virutalenv-inherit-from-another, but it is not really creating 2 virtualenvs, is there a better solution where somebody can either load the base virtualenv or the more specific virtualenv? – Andrea Zonca May 24 '12 at 21:30
  • Why not just include all the packages in the base virtualenv? – Jordan May 24 '12 at 21:45
  • 1
    @Jordan sometimes it could be useful to have the same base layer of packages, with different versions of other packages spread across the nested virtualenvs. – Brendan Wood May 24 '12 at 22:18
  • Then maybe you could just use multiple requirements.txt files. 1 for the base level, and then another for more particular items. – Jordan May 24 '12 at 22:30

2 Answers2

5

No, this isn't currently possible. There is a feature request and a patch for the functionality out there though:

https://github.com/pypa/virtualenv/issues/33

ire_and_curses
  • 68,372
  • 23
  • 116
  • 141
1

You can run in trouble when running python scripts of a virtualenv as subprocesses of another virtualenv. I've found useful to remove from the environment of the subprocess PYTHONPATH and BUILDOUT_ORIGINAL_PYTHONPATH.

sortega
  • 1,128
  • 9
  • 15