【发布时间】:2020-06-10 09:00:48
【问题描述】:
我有一个项目,我必须从 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+... 安装时不会发生错误...
如何解决这个解析错误?
到目前为止我已经尝试过:
- 用" / """ / ' / '''包裹字符串
- 在字符串前添加“r”
【问题讨论】:
-
@BramVanroy
dependency_links被宣布为过时,最后在pip19.0 中宣布removed。请撤回您的投票。 -
@phd 不过,这是同一个核心问题,重复问题的答案也回答了这个问题 (stackoverflow.com/a/54794506/1150683)。
-
@phd 更新了这个问题以具体说明 install_requires 以更好地区分问题并撤回我的投票。
标签: python git pip setuptools setup.py