使用私有devpi服务器与pipenv

时间:2018-03-28 13:56:56

标签: python pip pipenv devpi

我可以使用私有的本地pip服务器,使用devpi安装我的软件包。相应的配置是:

[global]
index_url = http://mydevpi.mine/root/pypi/+simple/

[search]
index = http://mydevpi.mine/root/pypi/

[install]
trusted-host = mydevpi.mine

使用pip安装然后很简单:

pip install -r requirements.txt

但对pipenv做同样的事情似乎不起作用。这有效,但未使用我的本地devpi

[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

这不起作用:

[[source]]

url = "http://devpi.dgv/root/pypi/+simple/"
verify_ssl = true
name = "pypi"

如何告诉pipenv使用pypi的其他网址?

2 个答案:

答案 0 :(得分:0)

也许,我可以在遇到类似问题时澄清一下。没有错误消息,但我看到很多流量到pypi.org(此流量是不需要的)

我在我的hosts文件中屏蔽了pypi.org并想强制使用我的devpi服务器,但是,pipenv安装失败。

Current constraints:
  ipykernel

Finding the best candidates:

INFO:pip9._vendor.requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 10.56.0.120
INFO:pip9._vendor.requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): wiki.pm1a.com
INFO:pip9._vendor.requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): pypi.org
WARNING:pip9._vendor.requests.packages.urllib3.connectionpool:Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip9._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x000002D74F344518>: Failed to establish a new connection: [WinError 10061] Es konnte keine Verbindung hergestellt werden, da der Zielcomputer die Verbindung verweigerte',)': /simple/ipykernel/
INFO:pip9._vendor.requests.packages.urllib3.connectionpool:Starting new HTTPS connection (2): pypi.org
WARNING:pip9._vendor.requests.packages.urllib3.connectionpool:Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip9._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x000002D74F344B00>: Failed to establish a new connection: [WinError 10061] Es konnte keine Verbindung hergestellt werden, da der Zielcomputer die Verbindung verweigerte',)': /simple/ipykernel/
INFO:pip9._vendor.requests.packages.urllib3.connectionpool:Starting new HTTPS connection (3): pypi.org
WARNING:pip9._vendor.requests.packages.urllib3.connectionpool:Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip9._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x000002D74F33EB70>: Failed to establish a new connection: [WinError 10061] Es konnte keine Verbindung hergestellt werden, da der Zielcomputer die Verbindung verweigerte',)': /simple/ipykernel/
INFO:pip9._vendor.requests.packages.urllib3.connectionpool:Starting new HTTPS connection (4): pypi.org
WARNING:pip9._vendor.requests.packages.urllib3.connectionpool:Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip9._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x000002D74F33E438>: Failed to establish a new connection: [WinError 10061] Es konnte keine Verbindung hergestellt werden, da der Zielcomputer die Verbindung verweigerte',)': /simple/ipykernel/
INFO:pip9._vendor.requests.packages.urllib3.connectionpool:Starting new HTTPS connection (5): pypi.org
WARNING:pip9._vendor.requests.packages.urllib3.connectionpool:Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip9._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x000002D74F33E208>: Failed to establish a new connection: [WinError 10061] Es konnte keine Verbindung hergestellt werden, da der Zielcomputer die Verbindung verweigerte',)': /simple/ipykernel/
INFO:pip9._vendor.requests.packages.urllib3.connectionpool:Starting new HTTPS connection (6): pypi.org
Traceback (most recent call last):
  File "e:\python3\lib\site-packages\pipenv\vendor\pip9\_vendor\requests\packages\urllib3\connection.py", line 142, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "e:\python3\lib\site-packages\pipenv\vendor\pip9\_vendor\requests\packages\urllib3\util\connection.py", line 98, in create_connection
    raise err
  File "e:\python3\lib\site-packages\pipenv\vendor\pip9\_vendor\requests\packages\urllib3\util\connection.py", line 88, in create_connection
    sock.connect(sa)

我猜,它与github上的以下问题密切相关:https://github.com/pypa/pipenv/issues/1783

编辑: 似乎运行pipenv install --skip-lock在没有访问pypi.org的情况下针对devpi(或类似的东西)运行时解决了这个问题。这对我来说至少是解决方案(使用pipenv 11.10.0和python 3.6.4)

答案 1 :(得分:0)

提供的示例假定默认安装pypi服务器。

方法1:Pipfile

[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

[[source]]
url = "http://localhost:8080"
verify_ssl = false
name = "home"

[dev-packages]

[packages]
requests = {version="*", index="home"}
beautifulsoup4 = {version="*", index="home"}
pandas = "*"

方法2:命令行

$ pipenv install --pypi-mirror http://localhost:8080

$ pipenv update --pypi-mirror http://localhost:8080

$ pipenv sync --pypi-mirror http://localhost:8080

$ pipenv lock --pypi-mirror http://localhost:8080

$ pipenv uninstall --pypi-mirror http://localhost:8080

方法3:环境变量

export PIPENV_PYPI_MIRROR=http://localhost:8080

Pipenv Docs - Advanced