简体   繁体   English

Python virtualenv --system-site-packages - 意外的pip行为

[英]Python virtualenv --system-site-packages — unexpected pip behavior

I have a number of python services that each use virtualenvs. 我有许多python服务,每个服务使用virtualenvs。 I sometimes rebuild these environments, and would like to save time doing it. 我有时会重建这些环境,并希望节省时间。 mkvirtualenv --system-site-packages seems close to what I want, but it still has behavior I don't understand. mkvirtualenv --system-site-packages似乎接近我想要的,但它仍然有我不理解的行为。

One package I use is gevent (beta version), which I install directly from GitHub: sudo pip install -e git://github.com/surfly/gevent.git@1.0b4#egg=gevent . 我使用的一个包是gevent(beta版),我直接从GitHub sudo pip install -e git://github.com/surfly/gevent.git@1.0b4#egg=geventsudo pip install -e git://github.com/surfly/gevent.git@1.0b4#egg=gevent This is done outside of a virtualenv, so it goes into the system's site-packages . 这是在virtualenv之外完成的,因此它会进入系统的site-packages This works fine, and if I create a new virtualenv with --system-site-packages , it seems to be present, but with a different rev and egg specified: 这工作正常,如果我用--system-site-packages创建一个新的virtualenv,它似乎存在,但指定了不同的rev和egg:

[msherry@hostname:~]$ mkvirtualenv test --system-site-packages
New python executable in test/bin/python2.7
Also creating executable in test/bin/python
Installing setuptools............done.
Installing pip...............done.
[msherry@hostname:~]$ workon test
[msherry@hostname:~]$ pip freeze|grep gevent
-e git://github.com/surfly/gevent.git@15418fc8ff4460069cf42b4b0341969c54455ddd#egg=gevent-dev

It at least looks installed, though. 但它至少看起来已经安装了。 However, when I run pip install -e git://github.com/surfly/gevent.git@1.0b4#egg=gevent , the (slow) install process for gevent begins again -- it looks like I gain nothing by using --system-site-packages . 但是,当我运行pip install -e git://github.com/surfly/gevent.git@1.0b4#egg=gevent ,gevent的(慢)安装过程再次开始 - 看起来我通过使用获得了什么--system-site-packages

Ideally, I'd like pip to notice that the version of gevent I'm requesting is already present, and not try to install it again. 理想情况下,我想请注意我正在请求的gevent版本已经存在,而不是尝试再次安装它。 Is there any way to do what I'm attempting? 有什么方法可以做我正在尝试的事情吗?

When installing system wide, try a slightly different syntax. 在系统范围内安装时,请尝试稍微不同的语法。

sudo pip install git+git://github.com/surfly/gevent.git@1.0b4#egg=gevent

That is nearly the same as yours, except without the -e and includes the <vcs> prefix to your url. 这与你的几乎相同,除了没有-e并且在你的网址中包含<vcs>前缀。 Without this, pip says 没有这个,皮普说

AssertionError: Sorry, 'git://github.com/surfly/gevent.git' is a malformed VCS url. The format is <vcs>+<protocol>://<url>, eg svn+http://myrepo/svn/MyApp#egg=MyApp

I also noticed the same thing you did when installing packages via pip in 'editable' mode: I get the commit hash version, as you did with the output of your pip freeze | grep gevent 我也注意到你在“可编辑”模式下通过pip安装软件包时所做的事情:我得到了提交哈希版本,就像你对pip freeze | grep gevent的输出所做的那样 pip freeze | grep gevent

-e git://github.com/surfly/gevent.git@15418fc8ff4460069cf42b4b0341969c54455ddd#egg=gevent-dev

which corresponds to that version of gevent . 这对应于那个版本的gevent

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM