【发布时间】:2018-06-17 16:59:05
【问题描述】:
我正在尝试在 centos 中安装 psutil,但同样失败并出现 gcc 错误。我在这个论坛上提到了各种帖子,但没有一个有帮助。许多线程建议使用 pydev,但它已经存在于我的系统中
#sudo /opt/airwave/bin/pip install psutil
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=543 -DPSUTIL_LINUX=1 -I/opt/airwave/include/python2.7 -c psutil/_psutil_common.c -o build/temp.linux-x86_64-2.7/psutil/_psutil_common.o
psutil/_psutil_common.c:9:20: error: Python.h: No such file or directory
psutil/_psutil_common.c:25: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
psutil/_psutil_common.c:31: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
psutil/_psutil_common.c:42: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
psutil/_psutil_common.c:57: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
psutil/_psutil_common.c:73: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
psutil/_psutil_common.c: In function 'psutil_debug':
psutil/_psutil_common.c:87: warning: implicit declaration of function 'va_start'
psutil/_psutil_common.c:91: warning: implicit declaration of function 'va_end'
psutil/_psutil_common.c: In function 'psutil_setup':
psutil/_psutil_common.c:100: warning: implicit declaration of function 'getenv'
psutil/_psutil_common.c:100: warning: comparison between pointer and integer
psutil/_psutil_common.c:102: warning: comparison between pointer and integer
error: command 'gcc' failed with exit status 1
gcc 可用
[root@localhost /]# yum install gcc
Loaded plugins: downloadonly, fastestmirror, presto, security, verify, versionlock
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: centos.excellmedia.net
* extras: centos.excellmedia.net
* updates: centos.excellmedia.net
Package gcc-4.4.7-18.el6.x86_64 already installed and latest version
Nothing to do
[root@localhost /]#
python-devel 也到位了
Loaded plugins: downloadonly, fastestmirror, presto, security, verify, versionlock
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: centos.excellmedia.net
* extras: centos.excellmedia.net
* updates: centos.excellmedia.net
Package python-devel-2.6.6-66.el6_8.x86_64 already installed and latest version
Nothing to do
Python 版本是 2.7.4
[root@localhost /]# python
Python 2.7.4 (default, Apr 17 2013, 09:54:46)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Python.h 文件可用
[root@localhost /]# find / -name Python.h
/usr/include/python2.6/Python.h
[root@localhost /]#
有两个可用的 python 实例(默认版本 2.6 和用户安装的 2.7)
[root@localhost jvm]# /usr/bin/python
Python 2.6.6 (r266:84292, Aug 18 2016, 15:13:37)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
[root@localhost jvm]# /opt/airwave/bin/python
Python 2.7.4 (default, Apr 17 2013, 09:54:46)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
所以当我尝试 yum install python-devel 时,它会为 python2.6 安装 python 开发包,但我希望 yum 为 python 2.7 安装 python-devel
如果您需要任何信息,请查看并告诉我
【问题讨论】:
-
你把事情搞糊涂了。例如:你启动的Python是2.7,但是开发包是2.6的。 /usr/include/python2.6/Python.h 也不为编译器所知(gcc);它在 /opt/airwave/include/python2.7 中寻找它(显然)找不到它。
-
@CristiFati:是的,我的 gcc 找不到 Python.h 文件,如何包含它?我试过
gcc -I/usr/include/python2.6 /usr/include/python2.6/Python.h但这没有帮助 -
@CristiFati:
yum install python-devel已安装 2.6。有没有办法为 2.7 安装? -
我无权访问 RH 机器,但是您应该为 Python 安装 python-devel 包i> 您尝试构建的版本(在本例中为 2.7.*)。不再熟悉 rpm 名称(尝试 python-devel-2.7?但我猜 2.6 是您的 OS 版本的默认值)。以下是 RPM 列表,您可以手动下载并安装:rpmfind.net/linux/rpm2html/search.php?query=python-devel。此外,您可能需要在
pip install之前设置一些环境变量。 -
它因一些冲突错误而失败
Error: python-devel conflicts with python-2.6.6-66.el6_8.x86_64 Error: Package: python-devel-2.7.5-58.el7.x86_64 (/python-devel-2.7.5-58.el7.x86_64) Requires: libpython2.7.so.1.0()(64bit) Error: Package: python-devel-2.7.5-58.el7.x86_64 (/python-devel-2.7.5-58.el7.x86_64) Requires: /usr/bin/python2.7 You could try using --skip-broken to work around the problem。我创建了一个软链接ln -sf /opt/airwave/bin/python2.7 /usr/bin/python2.7,即使它失败了
标签: python python-2.7 gcc pip psutil