![](/img/trans.png)
[英]pip install does not install required dependencies declared with install_requires
[英]Pip does not install dependencies declared in setup.py with install_requires
在一个Python项目中,我在setup.py
使用install_requires
,如下所示。
install_requires=['numpy', 'scipy', 'matplotlib']
然后,我按如下方式创建源代码,二进制文件和wheel。
python setup.py sdist bdist bdist_wheel
发布时,我使用twine
。
twine upload --repository dist/testpypi mypackage-0.1.1-py2-none-any.whl
然后,在Python 2.7 conda环境中,我尝试测试安装。
pip install -i https://test.pypi.org/simple/ mypackage==0.1.1
但是,我收到以下错误消息:
ERROR: Could not find a version that satisfies the requirement matplotlib (from mypackage) (from versions: none) ERROR: No matching distribution found for matplotlib (from mypackage)
实际上,当我执行pip list
和conda list
,没有列出matplotlib
软件包。
我究竟做错了什么? 我以为(这一点是我的理解被打破的地方), install_requires
会列出先决条件,而pip install
会对此进行补充并自动安装需求? 但是,如果尚未安装声明的依赖项,则install_requires
似乎可以防止安装软件包。
在某些互联网搜索中,他们似乎建议我通过MANIFEST.in
包含一个requirements.txt
(例如, include requirements.txt
),然后pip install
将自动安装依赖项。 但是,尝试这种方法后,我仍然收到相同的错误消息。 我尝试了requirements.txt
,如下所示。
matplotlib
并且也如下。
matplotlib>=2.2.3
如何配置/设置setup.py
和我的发行版,例如pip install
或conda install
将通过install_requires
自动安装声明的依赖项?
问题是pip在与所选软件包相同的存储库中寻找软件包。 因此,如果您提供使用https://test.pypi.org/simple/
那么它将在此处查找软件包,而不是https://pypi.org/simple/
。
您认为您需要使用--extra-index-url
参数
--extra-index-url <url> Extra URLs of package indexes to use in addition to --index-url. Should follow the same rules as --index-url.
因此,请尝试:
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ mypackage==0.1.1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.