7

I am trying to install psutil in centos and same is failing with gcc error . I have referred various posts in this forum but none of them helped . Many threads suggested to use pydev but its already there in my system

#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 is available

[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 is also in place

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 version is 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 file is available

[root@localhost /]# find / -name Python.h
/usr/include/python2.6/Python.h
[root@localhost /]#

There are two instances of python available (default version 2.6 and user installed 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.
>>>

So when I try yum install python-devel , its installing python dev package for python2.6 but I want yum to install python-devel for python 2.7 Check and let me know if you need any information

Sandeep Lade
  • 1,865
  • 2
  • 13
  • 23
  • You are confusing things. E.g.: *Python* that you **launch** is *2.7*, but the development pkg is for *2.6*. Also the */usr/include/python2.6/Python.h* is unknown to the compiler (*gcc*); it looks for it in */opt/airwave/include/python2.7* where it (obviously) can't find it. – CristiFati Jan 08 '18 at 17:39
  • @CristiFati : Yes my gcc is not able to find Python.h file , how to include that ? I tried `gcc -I/usr/include/python2.6 /usr/include/python2.6/Python.h` but that didn't help – Sandeep Lade Jan 08 '18 at 17:49
  • @CristiFati : `yum install python-devel` installed 2.6 . Is there a way to install for 2.7 ? – Sandeep Lade Jan 08 '18 at 17:53
  • I don't have access to a *RH* machine, but you should install the *python-devel* package for the *Python* version that you try to build against (in this case 2.7.\*). No longer familiar with rpm names (try *python-devel-2.7*? but I guess 2.6 is the default for your *OS* version). Here's a list of *RPM*s, you could download and install manually: https://rpmfind.net/linux/rpm2html/search.php?query=python-devel. Also you might need to set some env vars before `pip install`. – CristiFati Jan 08 '18 at 17:55
  • Its failing with some conflict error `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` . I created a softlink `ln -sf /opt/airwave/bin/python2.7 /usr/bin/python2.7` even then it failed – Sandeep Lade Jan 08 '18 at 18:27
  • Trying to patch things manually is to be avoided if not especially knowing what you're doing. Try uninstalling the *2.6* package (*python-devel* and also *python* if present). You also need the *python27* rpm. Other than that, I don't know what to tell you without access to a console. – CristiFati Jan 08 '18 at 18:36
  • @CristiFati : Not able to uninstall python2.6 . I do have python2.7 installed but yum install is downloading python-devel for 2.7. When I try to download and install python-devel2.7 it couldn't find python2.7 in /usr/bin though there is a softlink exists . Any other suggestion ? – Sandeep Lade Jan 09 '18 at 05:40

1 Answers1

9

I wanted a solution for python 3.6 and the below solution worked for me.

sudo apt-get install python3.6-dev

Ojus sangoi
  • 636
  • 7
  • 7
  • 3
    Perfect! I had a similar problem: `psutil` not updating from version `5.7.0` to `5.7.1` under `python3.5`. Likewise, as suggested by @Ojus, I just installed the `libpython3.5-dev` (even no need to fully install `python3.5-dev`) and the problem was solved. – loved.by.Jesus Jul 16 '20 at 14:06
  • 1
    Still worth with Python-3.11 if someone comes to look with the same problem – madtyn Mar 29 '23 at 18:11