安装psutil模块报错的解决方法

'*' token
    psutil/_psutil_linux.c:190: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
    psutil/_psutil_linux.c:240: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
    psutil/_psutil_linux.c:268: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
    psutil/_psutil_linux.c:375: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
    psutil/_psutil_linux.c:433: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
    psutil/_psutil_linux.c:482: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
    psutil/_psutil_linux.c:543: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PsutilMethods'
    psutil/_psutil_linux.c:582: error: expected specifier-qualifier-list before 'PyObject'
    psutil/_psutil_linux.c: In function 'init_psutil_linux':
    psutil/_psutil_linux.c:628: error: 'PyObject' undeclared (first use in this function)
    psutil/_psutil_linux.c:628: error: (Each undeclared identifier is reported only once
    psutil/_psutil_linux.c:628: error: for each function it appears in.)
    psutil/_psutil_linux.c:628: error: 'v' undeclared (first use in this function)
    psutil/_psutil_linux.c:632: error: 'module' undeclared (first use in this function)
    psutil/_psutil_linux.c:632: warning: implicit declaration of function 'Py_InitModule'
    psutil/_psutil_linux.c:632: error: 'PsutilMethods' undeclared (first use in this function)
    psutil/_psutil_linux.c:635: warning: implicit declaration of function 'PyModule_AddIntConstant'
    error: command 'gcc' failed with exit status 1
    
    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-cY1TLx/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-J4cL69-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-cY1TLx/psutil/



===============================================================

解决方法是安装python-devel,这是Python的头文件和静态库包:

[root@localhost ~]# yum install python-devel.x86_64
Failed to set locale, defaulting to C
Loaded plugins: product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package python-devel.x86_64 0:2.6.6-51.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================
 Package                Arch             Version                  Repository              Size
===============================================================================================
Installing:
 python-devel           x86_64           2.6.6-51.el6             cdrom-server           171 k

Transaction Summary
===============================================================================================
Install       1 Package(s)

Total download size: 171 k
Installed size: 456 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : python-devel-2.6.6-51.el6.x86_64                                            1/1
  Verifying  : python-devel-2.6.6-51.el6.x86_64                                            1/1

Installed:
  python-devel.x86_64 0:2.6.6-51.el6                                                           

Complete!
在用pip安装psutil模块
[root@localhost ~]# pip install psutil
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
Collecting psutil
  Using cached psutil-5.0.1.tar.gz
Installing collected packages: psutil
  Running setup.py install for psutil ... done
Successfully installed psutil-5.0.1

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29065182/viewspace-2132875/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29065182/viewspace-2132875/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值