Modifying a virtualenv so that packages installed in global site-packages are available [duplicate]

流过昼夜 提交于 2019-11-30 12:52:10

问题


Possible Duplicate:
Revert the `--no-site-packages` option with virtualenv

I've created a virtual environment using the virtualenvwrapper documentation as follows:

$ pip install virtualenvwrapper
$ export WORKON_HOME=~/Envs
$ mkdir -p $WORKON_HOME
$ source /usr/local/bin/virtualenvwrapper.sh
$ mkvirtualenv env1

It works fine for the most part, but I've run into a few Django issues that require me to install some global packages outside of my virtual environment. Once I've installed these packages, how to I update my virtual environment to pull in these new packages? Or do I need to recreate the environment from scratch?


回答1:


This question is a partial duplicate of: Revert the `--no-site-packages` option with virtualenv

However since this question specifically mentions virtualenvwrapper, the simplest solution when using virtualenvwrapper is to simply use its toggleglobalsitepackages command:

$ toggleglobalsitepackages env1

Alternatively you can reinstall the virtualenv, reconfiguring it to have access to global packages, while keeping the packages already installed there with the command:

$ mkvirtualenv --system-site-packages env1

(thanks to @Adaephon for the heads up regarding toggleglobalsitepackages)



来源:https://stackoverflow.com/questions/12433198/modifying-a-virtualenv-so-that-packages-installed-in-global-site-packages-are-av

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!