Python 为什么pip安装失败,除非我锁定了一个版本?

Python 为什么pip安装失败,除非我锁定了一个版本?,python,pip,Python,Pip,我在pypi repo中有一个包,其中的版本有一个前缀,如package\u foo:bar-0.1.0 例如,我可以使用pip安装包\u foo>=bar-0,pip安装包\u foo==bar-0.1.0,pip安装包\u foo>=bar-0来安装此包,您的版本名/编号不兼容。因此, PIP < /代码>将其视为一个版本,不在默认情况下安装它。 添加需求说明符(如==bar-0.1.0)或使用--pre选项(pip-install--pre-package_-foo)应该可以解决您的问题

我在pypi repo中有一个包,其中的版本有一个前缀,如
package\u foo:bar-0.1.0


例如,我可以使用
pip安装包\u foo>=bar-0
pip安装包\u foo==bar-0.1.0
pip安装包\u foo>=bar-0来安装此包,您的版本名/编号不兼容。因此,<代码> PIP < /代码>将其视为一个版本,不在默认情况下安装它。

添加需求说明符(如
==bar-0.1.0
)或使用
--pre
选项(
pip-install--pre-package_-foo
)应该可以解决您的问题


我建议更改您的版本方案,使其符合PEP440和/或标准。

您能否提供
pip安装-vv package\u foo
的输出。它应该列出所有找到的版本。@AlexisBRENON addedIt似乎找到了该软件包,并且版本分析正确,但pip拒绝安装它。。。您的版本号不符合方案。您是否尝试使用更“经典”的版本号/名称(0.1.0+bar)?在我的例子中,我将包作为
0.1.0+bar
上传到我的pypi repo,现在一切正常
ERROR: Could not find a version that satisfies the requirement package_foo (from versions: bar-0.1.0)
ERROR: No matching distribution found for package_foo
Created temporary directory: /private/var/folders/mv/0frvv9jj44d68kzfvgw72wvc0000gn/T/pip-ephem-wheel-cache-2gg4a0q5
Created temporary directory: /private/var/folders/mv/0frvv9jj44d68kzfvgw72wvc0000gn/T/pip-req-tracker-p4ppfxwu
Created requirements tracker '/private/var/folders/mv/0frvv9jj44d68kzfvgw72wvc0000gn/T/pip-req-tracker-p4ppfxwu'
Created temporary directory: /private/var/folders/mv/0frvv9jj44d68kzfvgw72wvc0000gn/T/pip-install-1atqi_8x
Looking in indexes: https://pypi.example.com/repository/pypi-all/simple
1 location(s) to search for versions of package-foo:
* https://pypi.example.com/repository/pypi-all/simple/package-foo/
Getting page https://pypi.example.com/repository/pypi-all/simple/package-foo/
Found credentials in url for pypi.example.com
Looking up "https://pypi.example.com/repository/pypi-all/simple/package-foo/" in the cache
Request header has "max_age" as 0, cache bypassed
Starting new HTTPS connection (1): pypi.example.com:443
https://pypi.example.com:443 "GET /repository/pypi-all/simple/package-foo/ HTTP/1.1" 200 None
Updating cache with response from "https://pypi.example.com/repository/pypi-all/simple/package-foo/"
Analyzing links from page https://pypi.example.com/repository/pypi-all/simple/package-foo/
  Found link https://pypi.example.com/repository/pypi-all/packages/package-foo/bar-0.1.0/package_foo-bar-0.1.0.tar.gz#md5=ce310afa2f5ade4af3b216fd1ece0498 (from https://pypi.example.com/repository/pypi-all/simple/package-foo/), version: bar-0.1.0
Given no hashes to check 0 links for project 'package-foo': discarding no candidates
ERROR: Could not find a version that satisfies the requirement package_foo (from versions: bar-0.1.0)
Cleaning up...
Removed build tracker '/private/var/folders/mv/0frvv9jj44d68kzfvgw72wvc0000gn/T/pip-req-tracker-p4ppfxwu'
ERROR: No matching distribution found for package_foo
Exception information:
Traceback (most recent call last):
  File "/Users/yzT/Desktop/venv/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 153, in _main
    status = self.run(options, args)
  File "/Users/yzT/Desktop/venv/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 382, in run
    resolver.resolve(requirement_set)
  File "/Users/yzT/Desktop/venv/lib/python3.7/site-packages/pip/_internal/legacy_resolve.py", line 201, in resolve
    self._resolve_one(requirement_set, req)
  File "/Users/yzT/Desktop/venv/lib/python3.7/site-packages/pip/_internal/legacy_resolve.py", line 365, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "/Users/yzT/Desktop/venv/lib/python3.7/site-packages/pip/_internal/legacy_resolve.py", line 311, in _get_abstract_dist_for
    req.populate_link(self.finder, upgrade_allowed, self.require_hashes)
  File "/Users/yzT/Desktop/venv/lib/python3.7/site-packages/pip/_internal/req/req_install.py", line 225, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/Users/yzT/Desktop/venv/lib/python3.7/site-packages/pip/_internal/index.py", line 906, in find_requirement
    'No matching distribution found for %s' % req
pip._internal.exceptions.DistributionNotFound: No matching distribution found for package_foo