我有一个必须从git + https安装的项目:
我可以使其以这种方式工作:
virtualenv -p python3.5 bla
. bla/bin/activate
pip install numpy # must have numpy before the following pkg...
pip install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
但是,我想在install_requires
中的setup.py文件中使用它:
from setuptools import setup
setup(install_requires='git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI', setup_requires='numpy')
然后,从包含pip install -e .
的目录中选择setup.py
由于解析错误,这不起作用:
Complete output (1 lines):
error in bla_bla setup command: 'install_requires' must be a string or list of strings containing valid project/version requireme
nt specifiers; Invalid requirement, parse error at "'+https:/'"
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
如果我使用pip install -r requires.txt
进行安装(假设我在该文件中具有相同的字符串),而使用直接pip install git+...
时则不会发生此错误...
如何解决此解析错误?
到目前为止我尝试过的:
install_requires
必须是一个字符串或包含名称和可选URL的字符串列表,才能从以下位置获取包:
install_requires=[
'pycocotools @ git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
]
请参见https://pip.readthedocs.io/en/stable/reference/pip_install/#requirement-specifiers和https://www.python.org/dev/peps/pep-0440/#direct-references
这需要pip install
包括pip install .
,并且不能与python setup.py install
一起使用。