【问题标题】:NewConnectionError installing scipyNewConnectionError 安装 scipy
【发布时间】:2020-06-08 17:08:44
【问题描述】:

Python 版本:3.5.6
平台:Xilinx Ultrascale+

我正在尝试在我拥有的嵌入式 Linux 设备上安装 scipy。我已经使用以下命令成功安装了 numpy、matplotlib 和 urllib3。

python3 -m pip install matplotlib --user --proxy <company proxy> --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org

但是当我尝试安装 scipy 时,我得到以下信息:

Collecting scipy
  Downloading https://files.pythonhosted.org/packages/04/ab/e2eb3e3f90b9363040a3d885ccc5c79fe20c5b8a3caa8fe3bf47ff653260/scipy-1.4.1.tar.gz (24.6MB)
    100% |################################| 24.6MB 18.5MB/s
  Installing build dependencies ... error
  Complete output from command /usr/bin/python3 -m pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-1anmecmf --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org -- wheel setuptools Cython>=0.29.13 "numpy==1.13.3; python_version=='3.5' and platform_system!='AIX'" "numpy==1.13.3; python_version=='3.6' and platform_system!='AIX'" "numpy==1.14.5; python_version=='3.7' and platform_system!='AIX'" "numpy==1.17.3; python_version>='3.8' and platform_system!='AIX'" "numpy==1.16.0; python_version=='3.5' and platform_system=='AIX'" "numpy==1.16.0; python_version=='3.6' and platform_system=='AIX'" "numpy==1.16.0; python_version=='3.7' and platform_system=='AIX'" "numpy==1.17.3; python_version>='3.8' and platform_system=='AIX'" pybind11>=2.4.0:
  Ignoring numpy: markers 'python_version == "3.6" and platform_system != "AIX"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.7" and platform_system != "AIX"' don't match your environment
  Ignoring numpy: markers 'python_version >= "3.8" and platform_system != "AIX"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.5" and platform_system == "AIX"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.6" and platform_system == "AIX"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.7" and platform_system == "AIX"' don't match your environment
  Ignoring numpy: markers 'python_version >= "3.8" and platform_system == "AIX"' don't match your environment
  Collecting wheel
    Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f9e76c160>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/wheel/
    Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f9e76c550>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/wheel/
    Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f9e76c8d0>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/wheel/
    Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f9e76c278>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/wheel/
    Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f9e76c4e0>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/wheel/
    Could not find a version that satisfies the requirement wheel (from versions: )
  No matching distribution found for wheel

  ----------------------------------------
Command "/usr/bin/python3 -m pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-1anmecmf --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org -- wheel setuptools Cython>=0.29.13 "numpy==1.13.3; python_version=='3.5' and platform_system!='AIX'" "numpy==1.13.3; python_version=='3.6' and platform_system!='AIX'" "numpy==1.14.5; python_version=='3.7' and platform_system!='AIX'" "numpy==1.17.3; python_version>='3.8' and platform_system!='AIX'" "numpy==1.16.0; python_version=='3.5' and platform_system=='AIX'" "numpy==1.16.0; python_version=='3.6' and platform_system=='AIX'" "numpy==1.16.0; python_version=='3.7' and platform_system=='AIX'" "numpy==1.17.3; python_version>='3.8' and platform_system=='AIX'" pybind11>=2.4.0" failed with error code 1 in None

我正在尝试找出导致“NewConnectionError”错误的原因。我认为它正在尝试从不在 --trusted-host 列表中的站点下载更多文件。这是正确的,如果是,它试图访问哪个站点?

【问题讨论】:

  • 升级到 Python-3.6 或更新版本。

标签: python-3.x scipy pip


【解决方案1】:

我想我找到了问题的根源,但似乎没有一个简单的解决方案。

当您通过 setup.py 浏览 scipy-1.4.1.tar.gz 时,您会看到它将指向 GitHub 的下载 URL 传递到 numpy.distutils.core.setup。我认为安装例程正在尝试查看 GitHub 上是否有轮子。请注意,连接错误发生在它说“收集轮”之后。除非它使用公司代理,否则它永远无法访问 GitHub。但我看不到将代理地址从 pip 传递到 scipy 安装代码的方法。所以一切都停止了。

基本上,除非 pypi.org 上存在轮子,但在我的情况下(ARM 上的 linux)不存在轮子,那么我似乎不走运。从头开始编译我自己的轮子似乎是唯一的选择。

【讨论】:

    【解决方案2】:

    在与 SciPy 维护人员讨论后,我找到了问题的正确根源。

    问题的根源在于试图下载的东西没有通过原始pip 命令中指定的公司代理。起初我以为这是在 SciPy setup.py 脚本中。当我标记该问题并说问题出在 pip 时,SciPy 维护人员予以回击。事实证明他们是对的。我会在这里引用它们:

    rgommers:

    发生的事情是 pip 看到 SciPy 有一个 pyproject.toml 文件 其中包含构建依赖项,然后它会尝试下载。所以 要么这是一个不尊重代理的 pip 错误(看起来很可能在这里), 或者它在您的代理配置中。它没有发生在我们的 setup.py 文件。

    pip 尝试下载的依赖项是“wheel”。在上面的例子中甚至是这样说的:

    Collecting wheel
    

    但是用那个包名我不知道发生了什么。我认为这意味着它试图从另一个位置下载一个 SciPy 轮子。

    我能够通过单独安装轮子来解决我的问题:

    python3 -m pip install wheel --user --proxy <company proxy> --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org
    

    然后安装 SciPy。

    我的 pip 版本是 18.0。不知道最新有没有修复。

    【讨论】:

    猜你喜欢
    • 2020-02-02
    • 2018-10-17
    • 2018-02-03
    • 2016-10-24
    • 2017-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多