简体   繁体   English

PIP 无法安装依赖项

[英]PIP not able to install dependencies

I have built and published a package to pypi using poetry build, and have also specified dependencies which it uses inside pyproject.toml我已经使用poetry构建构建并发布了 package 到 pypi,并且还指定了它在pyproject.toml中使用的依赖项

[tool.poetry.dependencies]
python = "^3.6"
PyGithub = "1.54.1"
colorama = "0.4.4"
PyInquirer = "1.0.3"

However when I install and run this package on a computer without those installed, I get this error但是,当我在没有安装这些的计算机上安装并运行此 package 时,我收到此错误

ERROR: Could not find version that satisfies the requirement PyGithub==1.54.1 (from <my_package_name_here) (from versions: none)

ERROR: No matching distribution found for PyGithub==1.54.1 (from <my_package_name_here)

How can I make pip install those automatically whenever someone installs my package using pip install package ?每当有人使用pip install package安装我的 package 时,如何让pip自动安装这些? Or is it not possible?还是不可能? This looks like it's trying to install them but can't find them?这看起来像是在尝试安装它们但找不到它们?

So I figured out what was wrong - I was testing the package on test.pypi , and since I was doing that, it was trying to install the required dependencies from there, and not from the ordinary PyPi.所以我发现出了什么问题——我在 test.pypi 上测试package ,因为我这样做了,所以它试图从那里安装所需的依赖项,而不是从普通的 PyPi 安装。 When published to PyPi everything is working.当发布到 PyPi 时,一切正常。

Make sure your are using the public pypi repository index .确保您使用的是公共pypi 存储库索引 If not, probably you're using test.pypi or another private repository, which does not contains all dependencies you specified.如果不是,您可能正在使用test.pypi或另一个私有存储库,其中不包含您指定的所有依赖项。

In that case you can pass an extra repository index.在这种情况下,您可以传递一个额外的存储库索引。

Use pip extra-index-url使用 pip extra-index-url

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple PACKAGE==PACKAGE_VERSION

By using an extra index, if pip couldn't find a package in the private repository it'll take look at the oficial index.通过使用额外的索引,如果 pip 在私有存储库中找不到 package,它将查看官方索引。

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

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