On my office computer, I've made virtualenv one-for-rule-them-all
at the Dropbox folder. I want to use this environment both at work and at home. Is this possible? (currently I'm not successful)
Don't share virtual environments between projects If you have multiple projects that have roughly the same requirements, it might seem like a good idea to create a single virtual environment that both projects can share. Don't do it.
1 Answer. Kindly be informed that yes, it is possible to move it on the same platform. You can simply use --relocatable on an existing environment. But it will get changed based on the new location in order to call python and pip, etc.
✔ Use a Separate Virtual Environment for Each ProjectIdeally, you should have one new virtual environment for every Python-based project you work on. The main purpose of this is to keep the dependencies of every project isolated from both the system and each other.
Look into using the relocatable
option of virtualenv. For full documentation, see the virtualenv documentation on the subject.
One note of interest:
Also, this does not make your packages cross-platform. You can move the directory around, but it can only be used on other similar computers. Some known environmental differences that can cause incompatibilities: a different version of Python, when one platform uses UCS2 for its internal unicode representation and another uses UCS4 (a compile-time option), obvious platform changes like Windows vs. Linux, or Intel vs. ARM, and if you have libraries that bind to C libraries on the system, if those C libraries are located somewhere different (either different versions, or a different filesystem layout).
As an alternative to this approach, I would simply manage your project/setup dependencies with setup.py requirements (install_requires
, setup_requires
), or pip requirements.txt file. This is much more portable and cross-platform.
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