如果我创建一个虚拟包--这里是/tmp/样例_ package /setup.py(注意需求):
from distutils.core import setup
setup(name='my_project',
description="Just a test project",
version="1.0",
py_modules=['sample'],
install_requires=['requests > 0.12'])下面是/tmp/样例_package/sample.py:
import requests
def get_example():
return requests.get("http://www.example.com")现在,我创建了一个虚拟环境:
$ virtualenv /tmp/foobar --distribute -p python2.7
Running virtualenv with interpreter /usr/bin/python2.7
New python executable in /tmp/foobar/bin/python2.7
Also creating executable in /tmp/foobar/bin/python
Installing distribute.................................................................................................................................................................................................done.
Installing pip................done.
$ source /tmp/foobar/bin/activate我创建了一个具有冲突需求的requirements.pip 。
# this requires requests > 0.12:
file:///tmp/example_package
# but this conflicts:
requests==0.9.0Pip愉快地安装如下:
$ pip install -r requirements.pip [18:40:10]
Unpacking ./example_package
Running setup.py egg_info for package from file:///tmp/example_package
Downloading/unpacking requests==0.9.0 (from -r requirements.pip (line 3))
Downloading requests-0.9.0.tar.gz (55Kb): 55Kb downloaded
Running setup.py egg_info for package requests
Downloading/unpacking certifi>=0.0.4 (from requests==0.9.0->-r requirements.pip (line 3))
Downloading certifi-0.0.8.tar.gz (118Kb): 118Kb downloaded
Running setup.py egg_info for package certifi
Installing collected packages: requests, my-project, certifi
Running setup.py install for requests
Running setup.py install for my-project
Running setup.py install for certifi
Successfully installed requests my-project certifi
Cleaning up...为什么皮普允许这样做?我的example_package不能工作,因为它的要求没有得到满足。
发布于 2013-01-29 14:27:12
这是皮普的一个限制。需求文件高于包的要求。请参阅https://github.com/pypa/pip/issues/775#issuecomment-12748095
发布于 2013-01-22 12:47:58
从pip源代码来看,它似乎应该递归地将所有需求添加到一个大型RequirementSet中。然后以“重复需求”的异常崩溃.
嗯..。你确定你的setup.py是正确的吗?
Distutils有一个requires关键字,但没有install_requires:http://docs.python.org/2/distutils/setupscript.html#relationships-between-distributions-and-packages
因此,回答中提到了这一点:
https://stackoverflow.com/questions/14445169
复制相似问题