Reputation: 2779
I created my first virtual environment for a django app that I created following a tutorial guide. Now I'm not sure, can I use this very same environment (same name), or do I need to create a new virtual environment when I create a new project?
I understand using virtual environments keeps your individual project dependencies and package versions isolated but my projects all have the same version of django and python. So far I'm not installing any other libraries and I'd imagine they would all just use the same version too. Is there something else I am missing here?
I just experimented with creating a new virtual environment from the current virtual env and I'm now in the newly created one once I activated it. Is it ok to create a new virtual environment from within another virtual environment? Is that any different from doing so outside a virtual environment?
If I were to use the same named virtual environment that I used for the old project, for this new project, what would the implications be?
Upvotes: 2
Views: 1009
Reputation: 475
As You stated in Your question venv
(virtual environment) as in official python documentation allows You to create a snapshot of the dependencies that are used within a project so that You are not installing the dependencies in a "global" context which would mean Your main Python directory.
A virtual environment is a Python environment such that the Python interpreter, libraries and scripts installed into it are isolated from those installed in other virtual environments, and (by default) any libraries installed in a “system” Python, i.e., one which is installed as part of your operating system. A virtual environment is a directory tree which contains Python executable files and other files which indicate that it is a virtual environment.
So answering couple of the questions that were mentioned in Your post:
I would highly recommend for You to create named venv
for each project independently. In my mind that will limit the probability of errors happening if You make any changes to the environment such as package updates and so on.
Upvotes: 2