pip installwheel 随机失败

2024-01-15

我有一个在本地打包为wheel的python项目,我想在docker容器的虚拟环境中安装这个wheel,基于python:alpine3.7。我的问题是,有时我工作,有时它无法解决轮子中的依赖关系,似乎是随机的。

轮子的依赖关系是:

_install_requires = [
    'numpy>=1.15.0',
    'pandas>=0.21.0',
    'scipy>=1.0.0',
    'scikit-learn>=0.19.2'
]

我的dockerfile如下:

FROM python:alpine3.7

# install dependencies
# the lapack package is only in the community repository
RUN echo "http://dl-4.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
RUN apk --update add --no-cache --virtual .build-deps \
    gcc \
    freetype-dev

RUN apk add --update lapack-dev python py-pip python-dev &&\
    apk add --update linux-headers

# Install dependencies
RUN apk add --no-cache --virtual .build-deps \
    gfortran \
    musl-dev \
    g++ \
    make &&\
    ln -s /usr/include/locale.h /usr/include/xlocale.h

RUN pip install --upgrade pip && pip install virtualenv

RUN virtualenv -p python3 ./venv

ADD dist/project-as-wheel-py3-none-any.whl .

RUN . ./venv/bin/activate && pip install ./project-as-wheel-py3-none-any.whl

在构建docker容器时,有时会失败,典型的日志是:

Processing /project-as-wheel-py3-none-any.whl
Collecting scikit-learn>=0.19.2 (from project-as-wheel==0.2.6)
  Downloading https://files.pythonhosted.org/packages/25/b6/454cf208be93efa3db50ce06b732328c57ede005d1dcfa71d9a1548530b0/scikit-learn-0.19.2.tar.gz (9.7MB)
Collecting pandas>=0.21.0 (from project-as-wheel==0.2.6)
  Downloading https://files.pythonhosted.org/packages/3e/56/82c4d4c049294f87ebd05b65fdcbc9ed68bd23fb0a7e4469caf9a75d199f/pandas-0.23.3.tar.gz (10.5MB)
Collecting numpy>=1.15.0 (from project-as-wheel==0.2.6)
  Downloading https://files.pythonhosted.org/packages/3a/20/c81632328b1a4e1db65f45c0a1350a9c5341fd4bbb8ea66cdd98da56fe2e/numpy-1.15.0.zip (4.5MB)
Collecting scipy>=1.0.0 (from project-as-wheel==0.2.6)
  Downloading https://files.pythonhosted.org/packages/07/76/7e844757b9f3bf5ab9f951ccd3e4a8eed91ab8720b0aac8c2adcc2fdae9f/scipy-1.1.0.tar.gz (15.6MB)
Collecting python-dateutil>=2.5.0 (from pandas>=0.21.0->project-as-wheel==0.2.6)
  Downloading https://files.pythonhosted.org/packages/cf/f5/af2b09c957ace60dcfac112b669c45c8c97e32f94aa8b56da4c6d1682825/python_dateutil-2.7.3-py2.py3-none-any.whl (211kB)
Collecting pytz>=2011k (from pandas>=0.21.0->project-as-wheel==0.2.6)
  Downloading https://files.pythonhosted.org/packages/30/4e/27c34b62430286c6d59177a0842ed90dc789ce5d1ed740887653b898779a/pytz-2018.5-py2.py3-none-any.whl (510kB)
Collecting six>=1.5 (from python-dateutil>=2.5.0->pandas>=0.21.0->project-as-wheel==0.2.6)
  Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Building wheels for collected packages: scikit-learn, pandas, numpy, scipy
  Running setup.py bdist_wheel for scikit-learn: started
  Running setup.py bdist_wheel for scikit-learn: finished with status 'error'
  Complete output from command /venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-439jjmrz/scikit-learn/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-ogmdp3dv --python-tag cp37:
  Partial import of sklearn during the build process.
  Traceback (most recent call last):
    File "/tmp/pip-install-439jjmrz/scikit-learn/setup.py", line 168, in get_numpy_status
      import numpy
  ModuleNotFoundError: No module named 'numpy'
  Traceback (most recent call last):
    File "/tmp/pip-install-439jjmrz/scikit-learn/setup.py", line 148, in get_scipy_status
      import scipy
  ModuleNotFoundError: No module named 'scipy'
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-439jjmrz/scikit-learn/setup.py", line 269, in <module>
      setup_package()
    File "/tmp/pip-install-439jjmrz/scikit-learn/setup.py", line 249, in setup_package
      .format(numpy_req_str, instructions))
  ImportError: Numerical Python (NumPy) is not installed.
  scikit-learn requires NumPy >= 1.8.2.
  Installation instructions are available on the scikit-learn website: http://scikit-learn.org/stable/install.html    


  ----------------------------------------
  Failed building wheel for scikit-learn
  Running setup.py clean for scikit-learn
  Running setup.py bdist_wheel for pandas: started
  Running setup.py bdist_wheel for pandas: still running...
  Running setup.py bdist_wheel for pandas: still running...
  Running setup.py bdist_wheel for pandas: still running...
  Running setup.py bdist_wheel for pandas: still running...
  Running setup.py bdist_wheel for pandas: still running...
  Running setup.py bdist_wheel for pandas: still running...
  Running setup.py bdist_wheel for pandas: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/8d/e7/58/7a882c73419e95e6709d925abb4b56c719c9be59ef826fe01c
  Running setup.py bdist_wheel for numpy: started
  Running setup.py bdist_wheel for numpy: still running...
  Running setup.py bdist_wheel for numpy: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/77/d2/00/03180c22fc40b6f17f6a5c6ea0fa1689734a9cf4cf54179a1c
  Running setup.py bdist_wheel for scipy: started
  Running setup.py bdist_wheel for scipy: finished with status 'error'
  Complete output from command /venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-439jjmrz/scipy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-83ktidr8 --python-tag cp37:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-439jjmrz/scipy/setup.py", line 474, in <module>
      setup_package()
    File "/tmp/pip-install-439jjmrz/scipy/setup.py", line 450, in setup_package
      from numpy.distutils.core import setup
  ModuleNotFoundError: No module named 'numpy'    

  ----------------------------------------
  Failed building wheel for scipy
  Running setup.py clean for scipy
  Complete output from command /venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-439jjmrz/scipy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" clean --all:    

  `setup.py clean` is not supported, use one of the following instead:    

    - `git clean -xdf` (cleans all files)
    - `git clean -Xdf` (cleans all versioned files, doesn't touch
                        files that aren't checked into the git repo)    

  Add `--force` to your command to use it anyway if you must (unsupported).    


  ----------------------------------------
  Failed cleaning build dir for scipy
Successfully built pandas numpy
Failed to build scikit-learn scipy
Installing collected packages: scikit-learn, six, python-dateutil, pytz, numpy, pandas, scipy, project-as-wheel
  Running setup.py install for scikit-learn: started
    Running setup.py install for scikit-learn: finished with status 'error'
    Complete output from command /venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-439jjmrz/scikit-learn/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-dwajrs1d/install-record.txt --single-version-externally-managed --compile --install-headers /venv/include/site/python3.7/scikit-learn:
    Partial import of sklearn during the build process.
    Traceback (most recent call last):
      File "/tmp/pip-install-439jjmrz/scikit-learn/setup.py", line 168, in get_numpy_status
        import numpy
    ModuleNotFoundError: No module named 'numpy'
    Traceback (most recent call last):
      File "/tmp/pip-install-439jjmrz/scikit-learn/setup.py", line 148, in get_scipy_status
        import scipy
    ModuleNotFoundError: No module named 'scipy'
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-439jjmrz/scikit-learn/setup.py", line 269, in <module>
        setup_package()
      File "/tmp/pip-install-439jjmrz/scikit-learn/setup.py", line 249, in setup_package
        .format(numpy_req_str, instructions))
    ImportError: Numerical Python (NumPy) is not installed.
    scikit-learn requires NumPy >= 1.8.2.
    Installation instructions are available on the scikit-learn website: http://scikit-learn.org/stable/install.html    


    ----------------------------------------
Command "/venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-439jjmrz/scikit-learn/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-dwajrs1d/install-record.txt --single-version-externally-managed --compile --install-headers /venv/include/site/python3.7/scikit-learn" failed with error code 1 in /tmp/pip-install-439jjmrz/scikit-learn/

让我困惑的是 pip 设法安装了 numpy 和 pandas,然后无法安装 scipy 并声称“没有名为‘numpy’的模块”。

编辑:日志上的 TL;DR 是:

  1. pip 尝试安装 scikit-learn,但由于未安装 numpy 而失败。
  2. pip 尝试安装 pandas,成功。
  3. pip 尝试安装 numpy,成功。
  4. pip 尝试安装 scipy,由于未安装 numpy 而失败(但在上面的步骤 3 中已成功安装!)。
  5. pip 声明成功安装 pandas 和 numpy,但未能安装 scikit-learn 和 scipy。
  6. pip 再次尝试安装 scipy,再次失败,抱怨 numpy 未安装。
  7. 皮普放弃了。

Edit2:根据 Nuts 的建议,我将 dockerfile 中的相关行更改为

RUN . ./venv/bin/activate && pip install numpy && pip install scipy && pip install ./project-as-wheel-py3-none-any.whl

不太令人满意,因为我无法从 setup.py 中获取版本要求,但它可以工作。


将需求改为这样

_install_requires = [
    'numpy>= 1.8.2',
    'pandas>=0.21.0',
    'scipy>=1.0.0',
    'scikit-learn>=0.19.2'
]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

pip installwheel 随机失败 的相关文章

随机推荐

  • PHP IIS7 MSSQL 调用未定义的函数 sqlsrv_connect

    我有 MSSQL Server 2008 MS WINDOWS SERVER 2008 RC2 和 PHP 5 4 php info 有行 PHP PDO SQLSRV 54 NTS extension php pdo sqlsrv 54
  • 来自 gitlab-ci docker 的 SSH 在“SSH2_MSG_KEX_ECDH_REPLY”上失败

    我正在尝试从 GitLab CI 中运行的 Docker 部署容器通过 SSH 连接到远程网络服务器 我第一次尝试时确实成功连接了一次 现在它不断失败 调试输出的最后两行 完整输出如下 是 debug1 expecting SSH2 MSG
  • 如何关闭yarn@2 PnP?

    我正在使用纱线2 0 0 rc 27 工作区 TypeScript 我想关闭 PnP 并使用node modules再次 我尝试了以下设置package json installConfig pnp false 然而 Yarn 每次都使用
  • 主干视图扩展被污染

    我有一个代表模式的视图 该视图有一些属性 例如页脚额外类 我遇到一个问题 当某些模式改变它的值时 所有模式都会收到相同的属性 这是例子 var ModalView AlertingView extend className modal pa
  • iPhone 和 Core Data:如何在更新之间保留用户输入的数据?

    考虑一个包含动物目录的 iPhone 应用程序 该应用程序应允许用户为每只动物添加自定义信息 比如说评级 范围为 1 到 5 以及他们可以输入的有关该动物的一些注释 但是 用户将无法修改动物数据本身 假设当应用程序更新时 静态 目录部分应该
  • 如何使用 JScript 获取进程的主窗口句柄?

    JScript 中是否有任何方法可以通过提供进程名称来获取进程主窗口的句柄 这Process MainWindowHandle http msdn microsoft com en us library system diagnostics
  • 从开发迁移到云时从一个连接字符串切换到另一个连接字符串

    我正在开发一个云应用程序 当我在计算机上测试应用程序时 我希望在 Service Configuration cscfg 中按如下方式设置连接字符串
  • Jquery 窗口最小化切换

    我有一个 div 当您单击另一个 div 时 它会切换显示和不显示 我如何修改我的代码 以便当用户最小化整个浏览器窗口时它会自动切换 从视图中隐藏 div 以便当用户取消最小化窗口时 div 不再可见 最小化窗口 或切换到另一个应用程序 应
  • 将 REST 调用与“Activity”分离的最佳方法

    我正在使用 Retrofit 并希望当用户在我的活动之间导航时 REST 调用能够继续存在 而不是仅在配置更改时保留它们 几个选项 改进同步调用AsyncTask并将其放入保留的 任务片段 http www androiddesignpat
  • 如何通过adb获取android手机的电话号码?

    有没有办法通过adb获取手机的电话号码 我认为 dumpsys 是一个可能的答案 但系统服务似乎都没有跟踪手机自己的号码 iphonesubinfo服务 跟踪 订户信息 包括电话号码 很遗憾iphonesubinfo服务没有实现dump 方
  • 我们如何创建非对称安全密钥?

    我们如何在 C 中创建 AsymmetrySecurityKey 实际上 我们正在使用 AsymetricSecurityKey 创建签名凭据 这是我们的代码 Define const Key this should be private
  • 如何在jquery中单击按钮时获取所选下拉值的值

    我使用 Bootstrap 和 jquery 创建一个包含下拉菜单和按钮的动态表 我想在单击按钮时获取在 jquery 中选择的下拉菜单的值 下面是我的代码 table class table table bordered tbody fo
  • 计算图形的方向以将其拉直(在Python中)

    我有一个计算图形方向的代码和一个根据计算出的方向拉直图形的函数 当我运行代码时 方向似乎很好 但是当函数尝试拉直图形时 图形看起来像是变成了另一种形状 代码中可能有什么问题吗 代码 import numpy as np import mat
  • 获取或设置UIButtonTypeInfoLight的点击区域

    因此 类型为 UIButtonTypeInfoLight 的 UIButton 的可点击区域似乎比其框架大得多 因此 我无法在它旁边放置按钮 尝试点击它会点击信息按钮 infoButton frame CGRectMake 0 0 40 h
  • 当有全局指针时,为什么分叉的进程不会互相影响?

    我知道fork 函数创建一个与其父进程相同的进程 仅其具有的 PID 不同 它们最初具有相同的变量 并且对这些变量所做的更改不会相互影响 但是当全局指针变量被共享时会发生什么呢 我写了一些代码并打印出了结果 看起来父进程和子进程都有指向sa
  • 在 JavaScript 导入语法中使用括号

    我遇到了一个 JavaScript 库 它使用以下语法来导入库 import React Component PropTypes from react 上面的方法和下面的有什么区别 import React Component PropTy
  • 如何在运行时设置获取类型? + 休眠

    如何在 hibernate 3 2 运行时设置获取类型 session beginTransaction Customer customer session get getCustomerId session save customer s
  • ImportError:无法导入名称“HTMLAwareEntitySubstitution”

    我刚刚安装了 beautifulsoup4 4 1 0 并将 pip 升级到版本 9 0 1 当我写这个时 from bs4 import BeautifulSoup 出现错误 Traceback most recent call last
  • JUNG(Java Graph):如何防止顶点标签和边标签重叠?

    我目前正在使用Jung http jung sf net绘制图表 我真正的意思是图表而不是图表 问题在于顶点和边标签与顶点和边重叠 这会导致图表看起来很奇怪 这个问题并不局限于特定的布局算法 尽管我一直在使用 FRLayout 是否有可能告
  • pip installwheel 随机失败

    我有一个在本地打包为wheel的python项目 我想在docker容器的虚拟环境中安装这个wheel 基于python alpine3 7 我的问题是 有时我工作 有时它无法解决轮子中的依赖关系 似乎是随机的 轮子的依赖关系是 insta