首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在docker映像python上使用“pip install psutil”:3.9.13-al菠萝3.16错误: linux/ethtool.h未找到

在docker映像python上使用“pip install psutil”:3.9.13-al菠萝3.16错误: linux/ethtool.h未找到
EN

Stack Overflow用户
提问于 2022-08-12 03:37:59
回答 1查看 1K关注 0票数 3

我试图在docker python:3.9.13-alpine3.16中安装python模块psutil。

但它报告了以下错误:

代码语言:javascript
运行
复制
Building wheels for collected packages: psutil
  Building wheel for psutil (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for psutil (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [51 lines of output]
      /tmp/tmpb62wij4i.c:1:10: fatal error: linux/ethtool.h: No such file or directory
          1 | #include <linux/ethtool.h>
            |          ^~~~~~~~~~~~~~~~~
      compilation terminated.
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-39
      creating build/lib.linux-x86_64-cpython-39/psutil
      copying psutil/__init__.py -> build/lib.linux-x86_64-cpython-39/psutil
      copying psutil/_common.py -> build/lib.linux-x86_64-cpython-39/psutil
      copying psutil/_compat.py -> build/lib.linux-x86_64-cpython-39/psutil
      copying psutil/_psaix.py -> build/lib.linux-x86_64-cpython-39/psutil
      copying psutil/_psbsd.py -> build/lib.linux-x86_64-cpython-39/psutil
      copying psutil/_pslinux.py -> build/lib.linux-x86_64-cpython-39/psutil
      copying psutil/_psosx.py -> build/lib.linux-x86_64-cpython-39/psutil
      copying psutil/_psposix.py -> build/lib.linux-x86_64-cpython-39/psutil
      copying psutil/_pssunos.py -> build/lib.linux-x86_64-cpython-39/psutil
      copying psutil/_pswindows.py -> build/lib.linux-x86_64-cpython-39/psutil
      creating build/lib.linux-x86_64-cpython-39/psutil/tests
      copying psutil/tests/__init__.py -> build/lib.linux-x86_64-cpython-39/psutil/tests
      copying psutil/tests/__main__.py -> build/lib.linux-x86_64-cpython-39/psutil/tests
      copying psutil/tests/foo.py -> build/lib.linux-x86_64-cpython-39/psutil/tests
      copying psutil/tests/runner.py -> build/lib.linux-x86_64-cpython-39/psutil/tests
      copying psutil/tests/test_aix.py -> build/lib.linux-x86_64-cpython-39/psutil/tests
      copying psutil/tests/test_bsd.py -> build/lib.linux-x86_64-cpython-39/psutil/tests
      copying psutil/tests/test_connections.py -> build/lib.linux-x86_64-cpython-39/psutil/tests
      copying psutil/tests/test_contracts.py -> build/lib.linux-x86_64-cpython-39/psutil/tests
      copying psutil/tests/test_linux.py -> build/lib.linux-x86_64-cpython-39/psutil/tests
      copying psutil/tests/test_memleaks.py -> build/lib.linux-x86_64-cpython-39/psutil/tests
      copying psutil/tests/test_misc.py -> build/lib.linux-x86_64-cpython-39/psutil/tests
      copying psutil/tests/test_osx.py -> build/lib.linux-x86_64-cpython-39/psutil/tests
      copying psutil/tests/test_posix.py -> build/lib.linux-x86_64-cpython-39/psutil/tests
      copying psutil/tests/test_process.py -> build/lib.linux-x86_64-cpython-39/psutil/tests
      copying psutil/tests/test_sunos.py -> build/lib.linux-x86_64-cpython-39/psutil/tests
      copying psutil/tests/test_system.py -> build/lib.linux-x86_64-cpython-39/psutil/tests
      copying psutil/tests/test_testutils.py -> build/lib.linux-x86_64-cpython-39/psutil/tests
      copying psutil/tests/test_unicode.py -> build/lib.linux-x86_64-cpython-39/psutil/tests
      copying psutil/tests/test_windows.py -> build/lib.linux-x86_64-cpython-39/psutil/tests
      running build_ext
      building 'psutil._psutil_linux' extension
      creating build/temp.linux-x86_64-cpython-39
      creating build/temp.linux-x86_64-cpython-39/psutil
      gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_SIZEOF_PID_T=4 -DPSUTIL_VERSION=591 -DPSUTIL_LINUX=1 -DPSUTIL_ETHTOOL_MISSING_TYPES=1 -I/usr/local/include/python3.9 -c psutil/_psutil_common.c -o build/temp.linux-x86_64-cpython-39/psutil/_psutil_common.o
      gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_SIZEOF_PID_T=4 -DPSUTIL_VERSION=591 -DPSUTIL_LINUX=1 -DPSUTIL_ETHTOOL_MISSING_TYPES=1 -I/usr/local/include/python3.9 -c psutil/_psutil_linux.c -o build/temp.linux-x86_64-cpython-39/psutil/_psutil_linux.o
      psutil/_psutil_linux.c:19:10: fatal error: linux/version.h: No such file or directory
         19 | #include <linux/version.h>
            |          ^~~~~~~~~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for psutil
Failed to build psutil
ERROR: Could not build wheels for psutil, which is required to install pyproject.toml-based projects

复发过程:

python:3.9.13-alpine3.16

  • docker
  1. (在容器中)# apk添加构建基
  2. (在容器中)# pip安装psutil

关键错误:

/tmp/tmpb62wij4i.c:1:10:致命错误: linux/ethtool.h:没有这样的文件或目录

包括

^

psutil/_psutil_linux.c:19:10:致命错误: linux/version.h:没有此类文件或目录

包括

^

编译已终止。

错误:命令'/usr/bin/gcc‘失败,退出代码1

那么,我需要预先安装什么来修复呢?,谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-08-12 04:27:31

您需要添加linux标头包。

代码语言:javascript
运行
复制
apk add build-base linux-headers
python -m pip install psutil
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73329011

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档