While working on some automation scripts, I found the need to have some common packages available to all the scripts (like ipython and spyder) and installing only the, let's call it differential packages for each script. Is there a way to have nested virtual environment in python? That is, some way to set the environments so that python would first looks at the innermost environment; if not found, it would look on the second innermost environment and so on until reaching the system wide environment for a package?
The closest I could find was to use the venv module with the --system-site-packages option but I couldn't achieve what I looking for: first, I don't want to install packages on the system using root permissions; second, I couldn't find a way to nest virtual environments using this option.
What's the best way to achieve this nested virtual environments structure, if there's one?
No, there isn't any such "nesting" feature in venv
.
I think your best bet would be to define the common packages in a requirements file and then install those at the time when you create a new virtual environment
pip install -r requirements-common.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With