Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
headers/pyenv/my_env/include/site/python3.6/psutil检查日志以获得完整的命令输出。 (我的环境)[root@TestBedpyenv]# (我的环境)[root@TestBed代码]#/hl.py 回溯(最近一次呼叫最后一次): 文件“/hl.py”,第4行,在 导入psutil ModuleNotFoundError:没有名为“psutil”的模块_Python_Python 3.x_Linux_Pip_Psutil - Fatal编程技术网

headers/pyenv/my_env/include/site/python3.6/psutil检查日志以获得完整的命令输出。 (我的环境)[root@TestBedpyenv]# (我的环境)[root@TestBed代码]#/hl.py 回溯(最近一次呼叫最后一次): 文件“/hl.py”,第4行,在 导入psutil ModuleNotFoundError:没有名为“psutil”的模块

headers/pyenv/my_env/include/site/python3.6/psutil检查日志以获得完整的命令输出。 (我的环境)[root@TestBedpyenv]# (我的环境)[root@TestBed代码]#/hl.py 回溯(最近一次呼叫最后一次): 文件“/hl.py”,第4行,在 导入psutil ModuleNotFoundError:没有名为“psutil”的模块,python,python-3.x,linux,pip,psutil,Python,Python 3.x,Linux,Pip,Psutil,Linux的说明包括首先安装python开发库,然后安装psutil: sudo apt-get install gcc python3-dev sudo pip3 install psutil 您收到的错误报告缺少python3-dev中安装的python头文件。不是100%确定,但OL7使用yum而不是apt-get。yum或apt-get,无论安装软件的软件包管理器是什么,都需要安装python3-dev。我提供的代码片段来自psutil的文档,这不包括如何在所有linux变体上安装。嗨

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

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

您收到的错误报告缺少python3-dev中安装的python头文件。

不是100%确定,但OL7使用
yum
而不是
apt-get
。yum或apt-get,无论安装软件的软件包管理器是什么,都需要安装python3-dev。我提供的代码片段来自psutil的文档,这不包括如何在所有linux变体上安装。嗨,欢迎来到stackoverflow。发布一个好问题时,一定要说出你的目标是什么,以及你已经尝试实现了什么。我不想通过阅读2页日志来找出你真正想要做的事情。此外,关于基础设施问题,张贴您正在使用的环境总是很有用的。
(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'
sudo apt-get install gcc python3-dev
sudo pip3 install psutil