zoukankan      html  css  js  c++  java
  • 如何安装psutil以及提示缺少python.h头文件

    下载psutil
    下载地址https://pypi.python.org/packages/57/93/47a2e3befaf194ccc3d05ffbcba2cdcdd22a231100ef7e4cf63f085c900b/psutil-5.2.2.tar.gz#md5=bb98d48796cd76d9ccee871aad720f9c
    解压
    进入解压后的文件夹
    安装
    python setup.py install
    我的会报错,解决方法是安装python-devel
    过程如下

    [root@localhost ~]# wget -c https://pypi.python.org/packages/57/93/47a2e3befaf194ccc3d05ffbcba2cdcdd22a231100ef7e4cf63f085c900b/psutil-5.2.2.tar.gz#md5=bb98d48796cd76d9ccee871aad720f9c
    --2017-07-07 01:13:19--  https://pypi.python.org/packages/57/93/47a2e3befaf194ccc3d05ffbcba2cdcdd22a231100ef7e4cf63f085c900b/psutil-5.2.2.tar.gz
    Resolving pypi.python.org (pypi.python.org)... 151.101.76.223, 2a04:4e42:12::223
    Connecting to pypi.python.org (pypi.python.org)|151.101.76.223|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 348413 (340K) [binary/octet-stream]
    Saving to: ‘psutil-5.2.2.tar.gz’
    
    100%[======================================>] 348,413     1.43MB/s   in 0.2s   
    
    2017-07-07 01:13:20 (1.43 MB/s) - ‘psutil-5.2.2.tar.gz’ saved [348413/348413]
    
    [root@localhost ~]# ls
    anaconda-ks.cfg  initial-setup-ks.cfg  psutil-5.2.2.tar.gz
    a.sh             original-ks.cfg
    [root@localhost ~]# ls
    anaconda-ks.cfg  initial-setup-ks.cfg  psutil-5.2.2.tar.gz
    a.sh             original-ks.cfg
    [root@localhost ~]# tar zxf psutil-5.2.2.tar.gz 
    [root@localhost ~]# ls
    anaconda-ks.cfg  initial-setup-ks.cfg  psutil-5.2.2
    a.sh             original-ks.cfg       psutil-5.2.2.tar.gz
    [root@localhost ~]# cd psutil-5.2.2/
    [root@localhost psutil-5.2.2]# dir
    CREDITS       HISTORY.rst  LICENSE   MANIFEST.in  psutil.egg-info  setup.cfg
    DEVGUIDE.rst  IDEAS    make.bat  PKG-INFO     README.rst       setup.py
    docs          INSTALL.rst  Makefile  psutil   scripts      tox.ini
    [root@localhost psutil-5.2.2]# python setup.py install
    running install
    running bdist_egg
    running egg_info
    writing psutil.egg-info/PKG-INFO
    writing top-level names to psutil.egg-info/top_level.txt
    writing dependency_links to psutil.egg-info/dependency_links.txt
    reading manifest file 'psutil.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: manifest_maker: MANIFEST.in, line 14: 'recursive-include' expects <dir> <pattern1> <pattern2> ...
    
    warning: no previously-included files matching '*' found under directory 'docs/_build'
    warning: no previously-included files matching '*' found under directory '.ci'
    writing manifest file 'psutil.egg-info/SOURCES.txt'
    installing library code to build/bdist.linux-x86_64/egg
    running install_lib
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/psutil
    copying psutil/_psposix.py -> build/lib.linux-x86_64-2.7/psutil
    copying psutil/_psbsd.py -> build/lib.linux-x86_64-2.7/psutil
    copying psutil/_pssunos.py -> build/lib.linux-x86_64-2.7/psutil
    copying psutil/_pslinux.py -> build/lib.linux-x86_64-2.7/psutil
    copying psutil/_common.py -> build/lib.linux-x86_64-2.7/psutil
    copying psutil/__init__.py -> build/lib.linux-x86_64-2.7/psutil
    copying psutil/_psosx.py -> build/lib.linux-x86_64-2.7/psutil
    copying psutil/_compat.py -> build/lib.linux-x86_64-2.7/psutil
    copying psutil/_pswindows.py -> build/lib.linux-x86_64-2.7/psutil
    creating build/lib.linux-x86_64-2.7/psutil/tests
    copying psutil/tests/test_bsd.py -> build/lib.linux-x86_64-2.7/psutil/tests
    copying psutil/tests/test_memory_leaks.py -> build/lib.linux-x86_64-2.7/psutil/tests
    copying psutil/tests/test_system.py -> build/lib.linux-x86_64-2.7/psutil/tests
    copying psutil/tests/test_linux.py -> build/lib.linux-x86_64-2.7/psutil/tests
    copying psutil/tests/test_misc.py -> build/lib.linux-x86_64-2.7/psutil/tests
    copying psutil/tests/__init__.py -> build/lib.linux-x86_64-2.7/psutil/tests
    copying psutil/tests/test_osx.py -> build/lib.linux-x86_64-2.7/psutil/tests
    copying psutil/tests/test_process.py -> build/lib.linux-x86_64-2.7/psutil/tests
    copying psutil/tests/test_windows.py -> build/lib.linux-x86_64-2.7/psutil/tests
    copying psutil/tests/runner.py -> build/lib.linux-x86_64-2.7/psutil/tests
    copying psutil/tests/test_posix.py -> build/lib.linux-x86_64-2.7/psutil/tests
    copying psutil/tests/test_sunos.py -> build/lib.linux-x86_64-2.7/psutil/tests
    running build_ext
    building 'psutil._psutil_linux' extension
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/psutil
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=522 -DPSUTIL_LINUX=1 -I/usr/include/python2.7 -c psutil/_psutil_linux.c -o build/temp.linux-x86_64-2.7/psutil/_psutil_linux.o
    psutil/_psutil_linux.c:12:20: fatal error: Python.h: No such file or directory
     #include <Python.h>
                        ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    [root@localhost psutil-5.2.2]# yum install python-devel -y
    Loaded plugins: fastestmirror, langpacks
    Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
    base                                                     | 3.6 kB     00:00     
    extras                                                   | 3.4 kB     00:00     
    updates                                                  | 3.4 kB     00:00     
    (1/2): extras/7/x86_64/primary_db                          | 188 kB   00:00     
    (2/2): updates/7/x86_64/primary_db                         | 7.7 MB   00:04     
    Determining fastest mirrors
     * base: mirror.bit.edu.cn
     * extras: mirrors.sohu.com
     * updates: mirrors.sohu.com
    Resolving Dependencies
    --> Running transaction check
    ---> Package python-devel.x86_64 0:2.7.5-48.el7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ================================================================================
     Package              Arch           Version                 Repository    Size
    ================================================================================
    Installing:
     python-devel         x86_64         2.7.5-48.el7            base         393 k
    
    Transaction Summary
    ================================================================================
    Install  1 Package
    
    Total download size: 393 k
    Installed size: 1.0 M
    Downloading packages:
    python-devel-2.7.5-48.el7.x86_64.rpm                       | 393 kB   00:00     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : python-devel-2.7.5-48.el7.x86_64                             1/1 
      Verifying  : python-devel-2.7.5-48.el7.x86_64                             1/1 
    
    Installed:
      python-devel.x86_64 0:2.7.5-48.el7                                            
    
    Complete!
    [root@localhost psutil-5.2.2]# python setup.py install
    。。。。该部分内容太多省略,安装成功

    重新进入python,导入psutil不再报错

    [root@localhost ~]# python
    Python 2.7.5 (default, Nov  6 2016, 00:28:07) 
    [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import psutil
    >>> 
    
  • 相关阅读:
    GetSystemMetrics SM_** 系统消息
    Direct3D中的HLSL
    Delphi TStream 详细介绍
    VI命令详解(大全)
    Delphi中messagedlg
    Windows中的消息详细列表
    SharePoint2007深入浅出——开发环境配置
    深入浅出InfoPath——预备式
    SharePoint术语对照表
    深入浅出Nintex——判断当前用户的角色
  • 原文地址:https://www.cnblogs.com/biaopei/p/7730532.html
Copyright © 2011-2022 走看看