0

In virtualenv, the option to inherit site packages from parent seems to be determined when it was created, and cannot be modified later.

This has created great inconvenience for dependency management, e.g. when the venv is referenced and dereferenced in Pycharm:

https://youtrack.jetbrains.com/issue/PY-38221?project=PY&clearDraft=true&description=PC-192.6817.19,%20JRE%2011.0.4%2010-b304.69x64%20JetBrains%20s.r.o,%20OS%20Linux(amd64)%20v5.0.0-29-generic,%20screens%201920x1080

The inheritance will be permanently disabled and never found again.

Is my impression correct? If not, what is the easiest way to achieve this feature?

tribbloid
  • 4,026
  • 14
  • 64
  • 103

2 Answers2

0

If I remember just recreate the virtualenv with the same target directory and with or without the --system-site-packages and it should toggle.

It least with older versions of virtualenv this worked if I recall correctly

gelonida
  • 5,327
  • 2
  • 23
  • 41
0

virtualenvwrapper has a command toggleglobalsitepackages.

phd
  • 82,685
  • 13
  • 120
  • 165
  • Sounds promising, unfortunately it only applies to environments created by this utility – tribbloid Sep 29 '19 at 19:48
  • All it does — creates or removes file `no-global-site-packages.txt`. `virtualenv` [does that](https://github.com/pypa/virtualenv/blob/35218c9ff4d90dd436f7c9a4d8eb10fc23d792e9/virtualenv.py#L1464) but only on creation. So I think you can just create/remove it manually. – phd Sep 29 '19 at 21:09
  • Thanks a lot! Let me try if I can remove it – tribbloid Sep 29 '19 at 21:25
  • yes. adding / removing no-global-site-packages.txt should be sufficient. – gelonida Oct 01 '19 at 10:29