【问题标题】:Use private devpi server with pipenv使用带有 pipenv 的私有 devpi 服务器
【发布时间】:2018-09-07 06:09:13
【问题描述】:

我可以使用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"

我如何告诉pipenvpypi 使用另一个网址?

【问题讨论】:

标签: python pip pipenv devpi


【解决方案1】:

也许,当我遇到类似的问题时,我可以澄清一下。没有错误消息,但我看到 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)

【讨论】:

    【解决方案2】:

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

    方法一: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

    【讨论】:

      猜你喜欢
      • 2019-02-18
      • 2019-09-26
      • 2017-01-19
      • 2016-11-06
      • 1970-01-01
      • 2022-11-03
      • 2013-10-10
      • 2022-07-21
      • 1970-01-01
      相关资源
      最近更新 更多