Pip 在 Artifactory 中找不到 PyPI 包

Posted

技术标签:

【中文标题】Pip 在 Artifactory 中找不到 PyPI 包【英文标题】:Pip can't find PyPI package in Artifactory 【发布时间】:2020-04-21 03:41:47 【问题描述】:

我使用 jfrog CLI 和命令构建 PyPI 包并推送到我们的本地 Artifactory:

tar.gz

./jfrog rt upload --url https://artifacts.XYZ.com/artifactory '--props=pypi.name=xyz_easysdlc.traceability_matrix_generator;pypi.version=0.0.1.dev20200102111901+dirty.0.g251f725.mock.develop;pypi.normalized.name=xyz-easysdlc-traceability-matrix-generator' --module=xyz_easysdlc.traceability_matrix_generator --user=**** '--password=****' dist/xyz_easysdlc.traceability_matrix_generator-0.0.1.dev20200102111901+dirty.0.g251f725.mock.develop.tar.gz pypi-main-dev/xyz_easysdlc.traceability_matrix_generator/0.0.1.dev20200102111901+dirty.0.g251f725.mock.develop/

***

./jfrog rt upload --url https://artifacts.xyz.com/artifactory '--props=pypi.name=xyz_easysdlc.traceability_matrix_generator;pypi.version=0.0.1.dev20200102111901+dirty.0.g251f725.mock.develop;pypi.normalized.name=xyz-easysdlc-traceability-matrix-generator' --module=xyz_easysdlc.traceability_matrix_generator --user=**** '--password=****' dist/xyz_easysdlc.traceability_matrix_generator-0.0.1.dev20200102111901+dirty.0.g251f725.mock.develop-py3-none-any.whl pypi-main-dev/xyz_easysdlc.traceability_matrix_generator/0.0.1.dev20200102111901+dirty.0.g251f725.mock.develop/

都上传成功。

当我通过以下步骤从 .whl 文件安装 pip 包时,它可以工作:

    下载https://artifacts.xyz.com/artifactory/webapp/#/artifacts/browse/tree/PyPIInfo/pypi-main-dev-local/xyz_easysdlc.traceability_matrix_generator/0.0.1.dev20200102111901+dirty.0.g251f725.mock.develop/xyz_easysdlc.traceability_matrix_generator-0.0.1.dev20200102111901+dirty.0.g251f725.mock.develop-py3-none-any.whl 运行pip install ~/Downloads/xyz_easysdlc.traceability_matrix_generator-0.0.1.dev20200102111901+dirty.0.g251f725.mock.develop-py3-none-any.whl

然后我会期望,那只是

pip install --pre --index-url https://artifacts.xyz.com/artifactory/api/pypi/pypi-main-dev/simple xyz_easysdlc.traceability_matrix_generator

可以,但我收到以下错误:

ERROR: Could not find a version that satisfies the requirement xyz_easysdlc.traceability_matrix_generator (from versions: none)
ERROR: No matching distribution found for xyz_easysdlc.traceability_matrix_generator

你们猜对了吗?

[更新] 当我以详细模式运行 pip install 时,我得到以下输出:

Created temporary directory: /private/var/folders/kq/3kr8fjgx6fv272mmnglm4lph_wfb11/T/pip-ephem-wheel-cache-u7ai32js
Created temporary directory: /private/var/folders/kq/3kr8fjgx6fv272mmnglm4lph_wfb11/T/pip-req-tracker-rxb7443i
Created requirements tracker '/private/var/folders/kq/3kr8fjgx6fv272mmnglm4lph_wfb11/T/pip-req-tracker-rxb7443i'
Created temporary directory: /private/var/folders/kq/3kr8fjgx6fv272mmnglm4lph_wfb11/T/pip-install-kegd0en3
Looking in indexes: https://artifacts.xyz.com/artifactory/api/pypi/pypi-main-dev/simple
1 location(s) to search for versions of xyz-easysdlc.traceability-matrix-generator:
* https://artifacts.xyz.com/artifactory/api/pypi/pypi-main-dev/simple/xyz-easysdlc-traceability-matrix-generator/
Getting page https://artifacts.xyz.com/artifactory/api/pypi/pypi-main-dev/simple/xyz-easysdlc-traceability-matrix-generator/
Found index url https://artifacts.xyz.com/artifactory/api/pypi/pypi-main-dev/simple
Looking up "https://artifacts.xyz.com/artifactory/api/pypi/pypi-main-dev/simple/xyz-easysdlc-traceability-matrix-generator/" in the cache
Request header has "max_age" as 0, cache bypassed
Starting new HTTPS connection (1): artifacts.xyz.com:443
https://artifacts.xyz.com:443 "GET /artifactory/api/pypi/pypi-main-dev/simple/xyz-easysdlc-traceability-matrix-generator/ HTTP/1.1" 404 None
Status code 404 not in (200, 203, 300, 301)
Could not fetch URL https://artifacts.xyz.com/artifactory/api/pypi/pypi-main-dev/simple/xyz-easysdlc-traceability-matrix-generator/: 404 Client Error: Not Found for url: https://artifacts.xyz.com/artifactory/api/pypi/pypi-main-dev/simple/xyz-easysdlc-traceability-matrix-generator/ - skipping
Given no hashes to check 0 links for project 'xyz-easysdlc.traceability-matrix-generator': discarding no candidates
ERROR: Could not find a version that satisfies the requirement xyz_easysdlc.traceability_matrix_generator (from versions: none)
Cleaning up...
Removed build tracker '/private/var/folders/kq/3kr8fjgx6fv272mmnglm4lph_wfb11/T/pip-req-tracker-rxb7443i'
ERROR: No matching distribution found for xyz_easysdlc.traceability_matrix_generator
Exception information:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 153, in _main
    status = self.run(options, args)
  File "/usr/local/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 382, in run
    resolver.resolve(requirement_set)
  File "/usr/local/lib/python3.7/site-packages/pip/_internal/legacy_resolve.py", line 201, in resolve
    self._resolve_one(requirement_set, req)
  File "/usr/local/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 "/usr/local/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 "/usr/local/lib/python3.7/site-packages/pip/_internal/req/req_install.py", line 225, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/usr/local/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 xyz_easysdlc.traceability_matrix_generator

但是当我导航到https://artifacts.xyz.com/artifactory/api/pypi/pypi-main-dev/simple/xyz-easysdlc-traceability-matrix-generator/ 时,我可以同时看到 *.whl 和 *.tar.gz 文件。只是为了确保,某些“无效”包名不是问题,这里是文件名。

xyz_easysdlc.traceability_matrix_generator-0.0.1.dev20200102111901+dirty.0.g251f725.mock.develop-py3-none-any.whl
xyz_easysdlc.traceability_matrix_generator-0.0.1.dev20200102111901+dirty.0.g251f725.mock.develop.tar.gz

【问题讨论】:

添加详细输出时的输出是什么,例如pip install -vvv ...? 另外,当你访问https://artifacts.xyz.com/artifactory/api/pypi/pypi-main-dev/simple时,它会列出你的包裹吗? 感谢@DustinIngram 的提示。我在问题本身中提供了这些信息。 您的仓库是否需要身份验证?如果你运行curl https://artifacts.xyz.com/artifactory/api/pypi/pypi-main-dev/simple/xyz-easysdlc-traceability-matrix-generator/,你会得到什么? @DustinIngram 非常感谢,实际上您找到了问题的根本原因。当我使用身份验证时,我能够使用 pip install。我会发现我们的 Artifactory 本地实例配置错误。无论如何,现在问题已经解决了。非常感谢。 【参考方案1】:

我找到了这个问题的根本原因。即使您未获得授权,Artifactory 也会发送 HTTP 代码 404 (v. 6.10.7)。当我验证pip install时,安装成功。

【讨论】:

以上是关于Pip 在 Artifactory 中找不到 PyPI 包的主要内容,如果未能解决你的问题,请参考以下文章

为啥我在命令提示符中找不到 PIP? [复制]

Python - 在 Windows 中找不到 pip.ini 或 pip.conf

Ubuntu中找不到pip3命令的解决方法

安装 pyaudio 时,pip 在 /usr/local/include 中找不到 portaudio.h

我已经用pip安装了statsmodels 但是pycharm中找不到它,pycharm也无法安装

Pycharm:“在 'image.py' 中找不到参考 'load'”