简体   繁体   English

pip 无法从本地 pypi 中找到包(jfrog artifactory)

[英]pip cannot find package from local pypi (jfrog artifactory)

We have a local pypi in which we put some python packages.我们有一个本地 pypi,我们在其中放置了一些 python 包。 However, pip is unable to install the package.但是,pip 无法安装该软件包。

pip search will find the package: pip search 会找到这个包:

$ pip search --index=http://artifactory.ours.com/api/pypi/pypi-local/simple hello        
hello     - UNKNOWN

But pip install gives the following:但是 pip install 给出了以下内容:

pip install --pre -r requirements.txt --trusted-host=artifactory.ours.com

Collecting hello (from -r requirements.txt (line 4)) Could not find a version that satisfies the requirement hello (from -r requirements.txt (line 4)) (from versions: ) No matching distribution found for hello (from -r requirements.txt (line 4))收集 hello(来自 -r requirements.txt(第 4 行))找不到满足要求的版本 hello(来自 -r requirements.txt(第 4 行))(来自版本:)没有找到匹配的 hello 发行版(来自 - r requirements.txt(第 4 行))

and here is the requirements.txt:这是requirements.txt:

# requirements.txt
--allow-all-external
--extra-index-url http://artifactory.ours.com/artifactory/api/pypi/pypi-local/simple

hello

I believe the issue is that your package does not have a version number.我认为问题在于您的软件包没有版本号。 Your setup.py does not specify the version.您的 setup.py 未指定版本。

Example from the Python documents (the example is for distutils): Python 文档中的示例(示例适用于 distutils):

https://docs.python.org/2/distutils/setupscript.html https://docs.python.org/2/distutils/setupscript.html

So the problem seems to be lifted if I use an older version of pip like 1.x .所以如果我使用像1.x这样的旧版本的 pip ,这个问题似乎就解决了。 Not sure if this is jfrog bug or related to pip itself.不确定这是 jfrog 错误还是与 pip 本身有关。

Another possible cause for this issue is when you use hyphen(-) in the name of the package while uploading it to artifactory.此问题的另一个可能原因是当您在将包上传到 artifactory 时在包名称中使用连字符 (-)。 pip can successfully search and find your package but it cannot install it. pip 可以成功搜索并找到您的软件包,但无法安装它。 Replace the hyphen with underscore.用下划线替换连字符。

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

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