jay*_*yde 6 python pip nexus localserver
已将本地nexus服务器设置为我们的pip本地服务器.我正在尝试使用所述本地服务器安装示例/测试类(继承).上传到本地服务器是成功的,但使用此命令安装:
pip install -i http://<nexus-ip>:8081/repository/pypi-all/pypi inherits
Run Code Online (Sandbox Code Playgroud)
导致这个问题:
Could not find a version that satisfies the requirement inherits
(from versions: )
No matching distribution found for inherits
Run Code Online (Sandbox Code Playgroud)
我也试过这些命令,但结果是一样的:
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
Run Code Online (Sandbox Code Playgroud)
这是我的〜/ .pypirc的内容:
[distutils]
index-servers =
nexus
pypi
[nexus]
username: my-username
password: mypassword
repository: http://<nexus-ip>:8081/nexus/repository/pypi-internal/
[pypi]
...
Run Code Online (Sandbox Code Playgroud)
这是我的〜/ .config/pip/pip.conf的内容
[global]
index = http://<nexus-ip>:8081/repository/pypi-all/pypi
index-url = http://<nexus-ip>:8081/repository/pypi-all/simple
Run Code Online (Sandbox Code Playgroud)
如上所述,使用以下命令上传是成功的:
python setup.py sdist upload -r nexus
Run Code Online (Sandbox Code Playgroud)
来自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
Run Code Online (Sandbox Code Playgroud)
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 = [],
)
Run Code Online (Sandbox Code Playgroud)
有关如何解决此问题并使pip安装工作的任何想法?提前致谢!
jay*_*yde 10
如果有人遇到同样的问题并且对解决方案感兴趣,这里有两件事我做了.
1.执行pip使用:
pip install inherits -i http://<nexus-ip>:8081/nexus/repository/pypi-all/simple -v --trusted-host <nexus-ip>
Run Code Online (Sandbox Code Playgroud)
-v和--trusted-host参数是可选的
2.将〜/ .config/pip/pip.conf移动到〜/ .pip/pip.conf并执行:
pip install inherits -v —trusted-host <nexus-ip>
Run Code Online (Sandbox Code Playgroud)
只有#2遇到的挑战是pip将始终连接到nexus服务器.所以如果我想连接到pypi.org,我必须首先重命名pip.conf.
希望这有助于某人!
我遇到了同样的问题。我使用以下步骤来解决它。现在可以完美运行了。
在以下步骤中,替换
pypi-mw
为您的私有 Nexus pypi 注册表名称。
添加具有所有必要权限的 Nexus 用户
创建一个新角色。按您的 pypi 注册表名称过滤所有权限并将其全部添加。将新角色应用于您的用户(您可以稍后细化权限):
编辑 .pypirc 以获取上传凭据
把这个放入~/.pypirc
[distutils]
index-servers =
pypi
pypi-mw
[pypi]
repository: https://pypi.python.org/pypi
username: peter
[pypi-mw]
repository: https://my-private-registry.com/repository/pypi-mw/
username: peter
Run Code Online (Sandbox Code Playgroud)
编辑 pip.conf 以获取下载凭据
将其放入~/.pip/pip.conf
:
[global]
index = https://pypi.python.org/pypi/
index-url=https://pypi.python.org/simple/
extra-index-url=https://MY-NEXUS-USER:MY-NEXUS-PW@my-private-registry.com/repository/pypi-mw/simple/
trusted-host = my-private-registry.com
Run Code Online (Sandbox Code Playgroud)
试试看
如果一切正常,您现在可以选择将包上传到pypi
如下位置:
python setup.py bdist_wheel upload
Run Code Online (Sandbox Code Playgroud)
或者到您的私人注册表:
python setup.py bdist_wheel upload -r "pypi-mw"
Run Code Online (Sandbox Code Playgroud)
要安装软件包,您可以运行常用命令:
pip install mypackage --user
Run Code Online (Sandbox Code Playgroud)
它现在应该在两个注册表 (pypi
和pypi-mw
) 中搜索您的包。