使用 virtualenv 恢复 `--no-site-packages` 选项 [英] Revert the `--no-site-packages` option with virtualenv
问题描述
我使用 --no-site-packages
选项创建了一个 virtualenv 并安装了许多库.现在我想恢复 --no-site-packages
选项并使用全局包.
I have created a virtualenv using the --no-site-packages
option and installed lots of libraries. Now I would like to revert the --no-site-packages
option and use also the global packages.
我可以在不重新创建 virtualenv 的情况下做到这一点吗?
Can I do that without recreating the virtualenv?
更准确地说:
我想知道使用 --no-site-packages
选项而不是不使用该选项创建 virtualenv 时究竟会发生什么.
I wonder what exactly happens when creating a virtualenv using the --no-site-packages
option as opposed to not using that option.
如果我知道会发生什么,那么我就能弄清楚如何撤消它.
If I know what happens then I can figure out how to undo it.
推荐答案
尝试删除(或重命名)您的 Lib
中的文件 no-global-site-packages.txt
> 虚拟环境下的文件夹.
Try removing (or renaming) the file no-global-site-packages.txt
in your Lib
folder under your virtual environment.
其中venv是你的虚拟环境的名字,python3.4对应的是python的哪个版本,例如:
Where venv is the name of your virtual environment, and python3.4 corresponds to whichever version of python involved, for example:
$ rm venv/lib/python3.4/no-global-site-packages.txt
如果你改变主意并想把它放回去:
And if you change your mind and want to put it back:
$ touch venv/lib/python3.4/no-global-site-packages.txt
注意:如果您没有看到上述文件,那么您有一个较新版本的 virtualenv.你会想要关注这个答案
Note: If you don't see the above file, then you have a newer version of virtualenv. You'll want to follow this answer instead
这篇关于使用 virtualenv 恢复 `--no-site-packages` 选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!