I have two, related Python projects:
../src/project_a
../src/project_a/requirements.txt
../src/project_a/project_a.py
../src/project_b
../src/project_b/requirements.txt
../src/project_b/project_b.py
Both projects use the same version of Python. The respective requirements.txt
files are similar but not identical.
Do I create a separate virtual environment for each project or can I create a "global" virtual environment at the ../src
level?
Note: I'm obviously new to using virtual environments.
Virtual environments are meant to keep things isolated from each other.
That's basically the only rules (I can think of). To me the rest is just a mix of best practices, personal opinions, common sense, technical limitations, and so on.
One could think of the pet vs cattle analogy (again) for example. Virtual environments can be seen as throw away things, that are created on demand (automatically with tools such as tox for example), which is easy once the dependencies are clearly written down (in requirements.txt
for example).
In your case, I would probably start with a single Python virtual environment, and only start creating more when the need arises. Most likely this will happen once the projects grow in size. And eventually it could become an absolute necessity once a project requires specific versions of dependencies that conflict with the dependencies of the other.
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