当前位置: 首页 > 知识库问答 >
问题:

ModuleNotFoundError:没有名为psutil的模块[重复]

子车俊材
2023-03-14

尝试使用pip安装模块,但出现以下错误?有人能帮忙吗。

我的机器是OEL7

(my_env) [root@TestBed pyenv]# pip3 install psutil
Collecting psutil
  Using cached psutil-5.7.2.tar.gz (460 kB)
Using legacy 'setup.py install' for psutil, since package 'wheel' is not installed.
Installing collected packages: psutil
    Running setup.py install for psutil ... error
    ERROR: Command errored out with exit status 1:
     command: /pyenv/my_env/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-kptxsdoz/psut                                                                                                           il/setup.py'"'"'; __file__='"'"'/tmp/pip-install-kptxsdoz/psutil/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__)                                                                                                           ;code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tm                                                                                                           p/pip-record-o82cl8pc/install-record.txt --single-version-externally-managed --compile --install-headers /pyenv/my_env/include/sit                                                                                                           e/python3.6/psutil
         cwd: /tmp/pip-install-kptxsdoz/psutil/
    Complete output (45 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.6
    creating build/lib.linux-x86_64-3.6/psutil
    copying psutil/_pswindows.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_psbsd.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_compat.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_common.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_psposix.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/__init__.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_psaix.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_pslinux.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_pssunos.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_psosx.py -> build/lib.linux-x86_64-3.6/psutil
    creating build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_aix.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_system.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_testutils.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_bsd.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_connections.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_memleaks.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_unicode.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_posix.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_windows.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_misc.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_sunos.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/__init__.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_osx.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_process.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_linux.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/__main__.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_contracts.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/runner.py -> build/lib.linux-x86_64-3.6/psutil/tests
    running build_ext
    building 'psutil._psutil_linux' extension
    creating build/temp.linux-x86_64-3.6
    creating build/temp.linux-x86_64-3.6/psutil
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protec                                                                                                           tor-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSUTIL_POSIX=1                                                                                                            -DPSUTIL_SIZEOF_PID_T=4 -DPSUTIL_VERSION=572 -DPSUTIL_LINUX=1 -I/pyenv/my_env/include -I/usr/include/python3.6m -c psutil/_psutil_                                                                                                           common.c -o build/temp.linux-x86_64-3.6/psutil/_psutil_common.o
    psutil/_psutil_common.c:9:20: fatal error: Python.h: No such file or directory
     #include <Python.h>
                        ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /pyenv/my_env/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"                                                                                                           '"'/tmp/pip-install-kptxsdoz/psutil/setup.py'"'"'; __file__='"'"'/tmp/pip-install-kptxsdoz/psutil/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-o82cl8pc/install-record.txt --single-version-externally-managed --compile --install-                                                                                                           headers /pyenv/my_env/include/site/python3.6/psutil Check the logs for full command output.
(my_env) [root@TestBed pyenv]# yum install gcc
Loaded plugins: langpacks, ulninfo
docker-ce-stable                                                                                           | 3.5 kB  00:00:00
ol7_UEKR5                                                                                                  | 2.5 kB  00:00:00
ol7_latest                                                                                                 | 2.7 kB  00:00:00
(1/2): ol7_UEKR5/x86_64/updateinfo                                                                         |  92 kB  00:00:00
(2/2): ol7_UEKR5/x86_64/primary_db                                                                         |  16 MB  00:00:06
Package gcc-4.8.5-39.0.5.el7.x86_64 already installed and latest version
Nothing to do
(my_env) [root@TestBed pyenv]# pip3 install psutil
Collecting psutil
  Using cached psutil-5.7.2.tar.gz (460 kB)
Using legacy 'setup.py install' for psutil, since package 'wheel' is not installed.
Installing collected packages: psutil
    Running setup.py install for psutil ... error
    ERROR: Command errored out with exit status 1:
     command: /pyenv/my_env/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-n7g7gqf_/psut                                                                                                           il/setup.py'"'"'; __file__='"'"'/tmp/pip-install-n7g7gqf_/psutil/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__)                                                                                                           ;code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tm                                                                                                           p/pip-record-cxodn_6f/install-record.txt --single-version-externally-managed --compile --install-headers /pyenv/my_env/include/sit                                                                                                           e/python3.6/psutil
         cwd: /tmp/pip-install-n7g7gqf_/psutil/
    Complete output (45 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.6
    creating build/lib.linux-x86_64-3.6/psutil
    copying psutil/_pswindows.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_psbsd.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_compat.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_common.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_psposix.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/__init__.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_psaix.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_pslinux.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_pssunos.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_psosx.py -> build/lib.linux-x86_64-3.6/psutil
    creating build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_aix.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_system.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_testutils.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_bsd.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_connections.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_memleaks.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_unicode.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_posix.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_windows.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_misc.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_sunos.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/__init__.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_osx.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_process.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_linux.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/__main__.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_contracts.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/runner.py -> build/lib.linux-x86_64-3.6/psutil/tests
    running build_ext
    building 'psutil._psutil_linux' extension
    creating build/temp.linux-x86_64-3.6
    creating build/temp.linux-x86_64-3.6/psutil
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protec                                                                                                           tor-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSUTIL_POSIX=1                                                                                                            -DPSUTIL_SIZEOF_PID_T=4 -DPSUTIL_VERSION=572 -DPSUTIL_LINUX=1 -I/pyenv/my_env/include -I/usr/include/python3.6m -c psutil/_psutil_                                                                                                           common.c -o build/temp.linux-x86_64-3.6/psutil/_psutil_common.o
    psutil/_psutil_common.c:9:20: fatal error: Python.h: No such file or directory
     #include <Python.h>
                        ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /pyenv/my_env/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"                                                                                                           '"'/tmp/pip-install-n7g7gqf_/psutil/setup.py'"'"'; __file__='"'"'/tmp/pip-install-n7g7gqf_/psutil/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-cxodn_6f/install-record.txt --single-version-externally-managed --compile --install-                                                                                                           headers /pyenv/my_env/include/site/python3.6/psutil Check the logs for full command output.
(my_env) [root@TestBed pyenv]#



(my_env) [root@TestBed code]# ./hl.py
Traceback (most recent call last):
  File "./hl.py", line 4, in <module>
    import psutil
ModuleNotFoundError: No module named 'psutil'

共有1个答案

陆宏壮
2023-03-14

Linux的说明包括:首先安装python开发库,然后安装psutil:

sudo apt-get install gcc python3-dev
sudo pip3 install psutil

您得到的错误报告丢失了安装在python3-dev中的python头文件。

 类似资料:
  • 问题内容: 我正在尝试导入“火炬”包。同样,我尝试使用如下pip命令安装它,安装甚至开始,但几秒钟后出现错误 下面是我执行的命令 我得到的错误: 操作系统: Windows。 IDE :pyCharm 我获得了与此问题相关的唯一链接,但无法解释它。 https://www.gitmemory.com/torch 问题答案: 任何正在寻找解决方案的人请参考以下内容: 似乎安装割炬的命令无法正常工作,

  • 问题内容: 完成我的一个Flask项目后,我像其他人一样将其上传到了github。在2-3个月的时间后,我将整个githube存储库下载到另一台计算机上以运行它。但是,该应用程序无法运行,因为未找到给出以下消息的软件包 ModuleNotFoundError:没有名为“ Flask”的模块 因此,我最终下载了从Flask,SQLalchemy等所有软件包。但我被困在: 有人可以帮忙解决这个问题吗?

  • 我安装了Crypto模块和SHA256,但显示ModuleNotFoundError:- 回溯(最后一次调用):文件“Digitalsig.py”,第1行,来自加密。哈希导入SHA256 ModuleNotFoundError:没有名为“Crypto”的模块 这是参考代码

  • 我目前试图安装一个名为pyvjoy的python模块(https://github.com/tidzo/pyvjoy),但我在导入后遇到一个错误 以下是错误: 回溯(最后一次调用):导入pyvjoy模块中导入PlayHelper文件“C:\Users\Slay\Desktop\RLBot master\PlayHelper.py”第1行第5行的文件“runner.py”错误:没有名为“pyvjoy

  • 我不能导入在PyCharm IDE在Mac上。我尝试过使用、、和简易安装来安装和卸载Keras,但都没有成功。我尝试过更换解释器(Python 2.7和3.6),但都不起作用。 在终端中,当我运行时: pip3列表|grep-i keras 我得到: Keras 2.2.2 Keras-应用程序1.0.4 Keras-预处理1.0.2 我认为这意味着我的Keras安装是成功的。我还通过以下方式检查

  • 但我得到的错误如下 1get_ipython()中的ModuleNotFoundError Traceback(最近一次调用)。run_line_magic('matplotlib','inline')2---- ModuleNotFoundError:没有名为“tensoflow”的模块 Tensoflow版本:1.15 Keras版本:2.2.0