我想使用以下目录层次结构
~/python/project-1
~/python/project-2
~/python/project-3
~/python/virtual-environments/environment-1 (virtual environment base)
~/python/virtual-environments/environment-2 (virtual environment base)
然后像这样使用它
# project-1 runs inside environment-1
source ~/python/virtual-environments/environment-1/bin/activate
cd ~/python/project-1/
python
# project-2 runs inside environment-2
source ~/python/virtual-environments/environment-2/bin/activate
cd ~/python/project-2/
python
# project-3 also runs inside environment-1
source ~/python/virtual-environments/environment-1/bin/activate
cd ~/python/project-3/
python
这是允许的还是会导致一些令人讨厌的问题?
我问,因为它似乎
~/python/virtual-environments/environment-1/ (virtual environment base)
~/python/virtual-environments/environment-1/project-1
~/python/virtual-environments/environment-1/project-3 (not sure if "allowed")
~/python/virtual-environments/environment-2/ (virtual environment base)
~/python/virtual-environments/environment-2/project-2
是“官方”的方式。我不想将项目紧密地绑定到环境中,并且多个项目也使用相同的环境,所以它不是内部/外部讨论,而是“完全在其他地方”。
答案 0 :(得分:2)
是的,没关系。甚至还有一个名为virtualenvwrapper的virtualenv的包装器,它做了类似的事情。默认情况下,它会将所有virtualenv存储在~/.virtualenvs
。