作为 pip 本地服务器的 Nexus 存储库管理器无法正常工作

新手上路,请多包涵

本地 nexus 服务器已设置为我们的 pip 本地服务器。我正在尝试使用所述本地服务器安装示例/测试类(继承)。上传到本地服务器是成功的,但是使用这个命令安装:

 pip install -i http://<nexus-ip>:8081/repository/pypi-all/pypi inherits

结果是:

   Could not find a version that satisfies the requirement inherits
  (from versions: )
  No matching distribution found for inherits

我也尝试了这些命令,但结果是一样的:

 pip install inherits
pip install -i http://<nexus-ip>:8081/repository/pypi-all/pypi inherits-0.1
pip install -i http://<nexus-ip>:8081/repository/pypi-all/pypi inherits==0.1

这是我的 ~/.pypirc 的内容:

 [distutils]
index-servers =
    nexus
    pypi

[nexus]
username: my-username
password: mypassword
repository: http://<nexus-ip>:8081/nexus/repository/pypi-internal/

[pypi]
...

这是我的 ~/.config/pip/pip.conf 的内容

[global]
index = http://<nexus-ip>:8081/repository/pypi-all/pypi
index-url = http://<nexus-ip>:8081/repository/pypi-all/simple

如前所述,使用以下命令上传成功:

 python setup.py sdist upload -r nexus

来自 Nexus 服务器的响应在这里(即表示上传成功):

 creating inherits-0.1
creating inherits-0.1/inherits
creating inherits-0.1/inherits.egg-info
copying files to inherits-0.1...
copying setup.cfg -> inherits-0.1
copying setup.py -> inherits-0.1
copying inherits/__init__.py -> inherits-0.1/inherits
copying inherits/addmult.py -> inherits-0.1/inherits
copying inherits/inherits.py -> inherits-0.1/inherits
copying inherits/subdiv.py -> inherits-0.1/inherits
copying inherits.egg-info/PKG-INFO -> inherits-0.1/inherits.egg-info
copying inherits.egg-info/SOURCES.txt -> inherits-0.1/inherits.egg-info
copying inherits.egg-info/dependency_links.txt -> inherits-0.1/inherits.egg-info
copying inherits.egg-info/top_level.txt -> inherits-0.1/inherits.egg-info
Writing inherits-0.1/setup.cfg
Creating tar archive
removing 'inherits-0.1' (and everything under it)
running upload
Submitting dist/inherits-0.1.tar.gz to http://<nexus-ip>:8081/nexus/repository/pypi-internal/
Server response (200): OK

setup.py 的内容是基本细节:

 #!/usr/bin/env python

import os
import sys

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

requires = []

setup(
    name = "inherits",
    packages = ["inherits"],
    version = '0.1',
    description = 'Example inherits package',
    #url = "",
    #download_url = "",
    author = "Jayson Pryde",
    classifiers = [],
)

关于如何解决这个问题并使 pip 安装工作的任何想法?提前致谢!

原文由 jaysonpryde 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 940
1 个回答

如果有人遇到同样的问题并且对解决方案感兴趣,我做了两件事。

1. 使用这个执行 pip:

 pip install inherits -i http://<nexus-ip>:8081/nexus/repository/pypi-all/simple -v --trusted-host <nexus-ip>

-v 和 –trusted-host 参数是可选的

2. 将你的 ~/.config/pip/pip.conf 移动到 ~/.pip/pip.conf 并执行:

 pip install inherits -v —trusted-host <nexus-ip>

#2 遇到的唯一挑战是 pip 将始终连接到 nexus 服务器。所以如果我想连接到 pypi.org,我必须先重命名 pip.conf。

希望这对某人有帮助!

原文由 jaysonpryde 发布,翻译遵循 CC BY-SA 3.0 许可协议

推荐问题