Skip to content

psutil fails to install on python3.6 and Ubuntu16.04 #1143

@KorewaKiyo

Description

@KorewaKiyo

install psutil with pip on python3.6 gives this error
I've tried installing different versions of psutil with the same error

Command "/usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_0xq2q7o/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-k4askr37-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-_0xq2q7o/psutil/

Activity

sethmlarson

sethmlarson commented on Oct 4, 2017

@sethmlarson

Can you post the install log that pip complains with here?

KorewaKiyo

KorewaKiyo commented on Oct 6, 2017

@KorewaKiyo
Author
Tommatheussen

Tommatheussen commented on Oct 6, 2017

@Tommatheussen

I'm having the same problem, using python 3.5.4 on Ubuntu 14.04, install logs below:

 pip3 install psutil
Collecting psutil
  Using cached psutil-5.3.1.tar.gz
Building wheels for collected packages: psutil
  Running setup.py bdist_wheel for psutil ... error
  Complete output from command /PlexMediaServer/hass/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-45z8bzr6/psutil/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmp59_mmtqmpip-wheel- --python-tag cp35:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-i686-3.5
  creating build/lib.linux-i686-3.5/psutil
  copying psutil/_psposix.py -> build/lib.linux-i686-3.5/psutil
  copying psutil/__init__.py -> build/lib.linux-i686-3.5/psutil
  copying psutil/_pswindows.py -> build/lib.linux-i686-3.5/psutil
  copying psutil/_common.py -> build/lib.linux-i686-3.5/psutil
  copying psutil/_pslinux.py -> build/lib.linux-i686-3.5/psutil
  copying psutil/_psosx.py -> build/lib.linux-i686-3.5/psutil
  copying psutil/_compat.py -> build/lib.linux-i686-3.5/psutil
  copying psutil/_psbsd.py -> build/lib.linux-i686-3.5/psutil
  copying psutil/_pssunos.py -> build/lib.linux-i686-3.5/psutil
  creating build/lib.linux-i686-3.5/psutil/tests
  copying psutil/tests/__init__.py -> build/lib.linux-i686-3.5/psutil/tests
  copying psutil/tests/test_misc.py -> build/lib.linux-i686-3.5/psutil/tests
  copying psutil/tests/test_posix.py -> build/lib.linux-i686-3.5/psutil/tests
  copying psutil/tests/test_system.py -> build/lib.linux-i686-3.5/psutil/tests
  copying psutil/tests/test_windows.py -> build/lib.linux-i686-3.5/psutil/tests
  copying psutil/tests/test_memory_leaks.py -> build/lib.linux-i686-3.5/psutil/tests
  copying psutil/tests/test_osx.py -> build/lib.linux-i686-3.5/psutil/tests
  copying psutil/tests/test_connections.py -> build/lib.linux-i686-3.5/psutil/tests
  copying psutil/tests/test_sunos.py -> build/lib.linux-i686-3.5/psutil/tests
  copying psutil/tests/__main__.py -> build/lib.linux-i686-3.5/psutil/tests
  copying psutil/tests/test_process.py -> build/lib.linux-i686-3.5/psutil/tests
  copying psutil/tests/test_bsd.py -> build/lib.linux-i686-3.5/psutil/tests
  copying psutil/tests/test_linux.py -> build/lib.linux-i686-3.5/psutil/tests
  copying psutil/tests/test_unicode.py -> build/lib.linux-i686-3.5/psutil/tests
  copying psutil/tests/test_contracts.py -> build/lib.linux-i686-3.5/psutil/tests
  running build_ext
  building 'psutil._psutil_linux' extension
  creating build/temp.linux-i686-3.5
  creating build/temp.linux-i686-3.5/psutil
  i686-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=531 -DPSUTIL_LINUX=1 -I/usr/include/python3.5m -I/PlexMediaServer/hass/include/python3.5m -c psutil/_psutil_common.c -o build/temp.linux-i686-3.5/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 'i686-linux-gnu-gcc' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for psutil
  Running setup.py clean for psutil
Failed to build psutil
Installing collected packages: psutil
  Running setup.py install for psutil ... error
    Complete output from command /PlexMediaServer/hass/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-45z8bzr6/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-r3gpqlml-record/install-record.txt --single-version-externally-managed --compile --install-headers /PlexMediaServer/hass/include/site/python3.5/psutil:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-i686-3.5
    creating build/lib.linux-i686-3.5/psutil
    copying psutil/_psposix.py -> build/lib.linux-i686-3.5/psutil
    copying psutil/__init__.py -> build/lib.linux-i686-3.5/psutil
    copying psutil/_pswindows.py -> build/lib.linux-i686-3.5/psutil
    copying psutil/_common.py -> build/lib.linux-i686-3.5/psutil
    copying psutil/_pslinux.py -> build/lib.linux-i686-3.5/psutil
    copying psutil/_psosx.py -> build/lib.linux-i686-3.5/psutil
    copying psutil/_compat.py -> build/lib.linux-i686-3.5/psutil
    copying psutil/_psbsd.py -> build/lib.linux-i686-3.5/psutil
    copying psutil/_pssunos.py -> build/lib.linux-i686-3.5/psutil
    creating build/lib.linux-i686-3.5/psutil/tests
    copying psutil/tests/__init__.py -> build/lib.linux-i686-3.5/psutil/tests
    copying psutil/tests/test_misc.py -> build/lib.linux-i686-3.5/psutil/tests
    copying psutil/tests/test_posix.py -> build/lib.linux-i686-3.5/psutil/tests
    copying psutil/tests/test_system.py -> build/lib.linux-i686-3.5/psutil/tests
    copying psutil/tests/test_windows.py -> build/lib.linux-i686-3.5/psutil/tests
    copying psutil/tests/test_memory_leaks.py -> build/lib.linux-i686-3.5/psutil/tests
    copying psutil/tests/test_osx.py -> build/lib.linux-i686-3.5/psutil/tests
    copying psutil/tests/test_connections.py -> build/lib.linux-i686-3.5/psutil/tests
    copying psutil/tests/test_sunos.py -> build/lib.linux-i686-3.5/psutil/tests
    copying psutil/tests/__main__.py -> build/lib.linux-i686-3.5/psutil/tests
    copying psutil/tests/test_process.py -> build/lib.linux-i686-3.5/psutil/tests
    copying psutil/tests/test_bsd.py -> build/lib.linux-i686-3.5/psutil/tests
    copying psutil/tests/test_linux.py -> build/lib.linux-i686-3.5/psutil/tests
    copying psutil/tests/test_unicode.py -> build/lib.linux-i686-3.5/psutil/tests
    copying psutil/tests/test_contracts.py -> build/lib.linux-i686-3.5/psutil/tests
    running build_ext
    building 'psutil._psutil_linux' extension
    creating build/temp.linux-i686-3.5
    creating build/temp.linux-i686-3.5/psutil
    i686-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=531 -DPSUTIL_LINUX=1 -I/usr/include/python3.5m -I/PlexMediaServer/hass/include/python3.5m -c psutil/_psutil_common.c -o build/temp.linux-i686-3.5/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 'i686-linux-gnu-gcc' failed with exit status 1
    
    ----------------------------------------
Command "/PlexMediaServer/hass/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-45z8bzr6/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-r3gpqlml-record/install-record.txt --single-version-externally-managed --compile --install-headers /PlexMediaServer/hass/include/site/python3.5/psutil" failed with error code 1 in /tmp/pip-build-45z8bzr6/psutil/

EDIT: I just updated from python 3.4.3, which did correctly install

kyb3r

kyb3r commented on Oct 6, 2017

@kyb3r

Same issue for me:

bob@hithere:~$ python3.6 -m pip install psutil
Collecting psutil
  Using cached psutil-5.3.1.tar.gz
Building wheels for collected packages: psutil
  Running setup.py bdist_wheel for psutil ... error
  Complete output from command /usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-z2l0ojsu/psutil/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmp0fnfdklipip-wheel- --python-tag cp36:
  running bdist_wheel
  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/_compat.py -> build/lib.linux-x86_64-3.6/psutil
  copying psutil/_common.py -> build/lib.linux-x86_64-3.6/psutil
  copying psutil/_psosx.py -> build/lib.linux-x86_64-3.6/psutil
  copying psutil/_pswindows.py -> build/lib.linux-x86_64-3.6/psutil
  copying psutil/__init__.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/_psposix.py -> build/lib.linux-x86_64-3.6/psutil
  copying psutil/_psbsd.py -> build/lib.linux-x86_64-3.6/psutil
  creating 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_system.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_bsd.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_unicode.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/__init__.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/test_misc.py -> build/lib.linux-x86_64-3.6/psutil/tests
  copying psutil/tests/test_memory_leaks.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/test_contracts.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_windows.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
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=531 -DPSUTIL_LINUX=1 -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
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for psutil
  Running setup.py clean for psutil
Failed to build psutil
Installing collected packages: psutil
  Running setup.py install for psutil ... error
    Complete output from command /usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-z2l0ojsu/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-bvrqh87n-record/install-record.txt --single-version-externally-managed --compile:
    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/_compat.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_common.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_psosx.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_pswindows.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/__init__.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/_psposix.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_psbsd.py -> build/lib.linux-x86_64-3.6/psutil
    creating 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_system.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_bsd.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_unicode.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/__init__.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/test_misc.py -> build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/test_memory_leaks.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/test_contracts.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_windows.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
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=531 -DPSUTIL_LINUX=1 -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
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    
    ----------------------------------------
Command "/usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-z2l0ojsu/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-bvrqh87n-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-z2l0ojsu/psutil/
giampaolo

giampaolo commented on Oct 6, 2017

@giampaolo
Owner

You guys need Python header files. On Ubuntu: sudo apt-get install python-dev.
On RedHat like distros it should be sudo yum install python-devel.

Tommatheussen

Tommatheussen commented on Oct 6, 2017

@Tommatheussen

I was just about to comment the same, after I read the install file: https://github.com/giampaolo/psutil/blob/master/INSTALL.rst
However, if you have multiple versions installed (like me, I have python 3.4.3 and 3.5.4 installed), you need to specify a more granular version, like so: sudo apt-get install python3.5-dev
After that, it installed without issues

KorewaKiyo

KorewaKiyo commented on Oct 6, 2017

@KorewaKiyo
Author

Thanks that worked!

rdhara

rdhara commented on Jun 15, 2018

@rdhara

@Tommatheussen Thank you that worked for me as well!

gnarizzy

gnarizzy commented on Jun 18, 2018

@gnarizzy

One more note that may be useful other people with this issue:

I'm using a RedHat distro and Python 2.7, and sudo yum install python-devel wasn't resolving the issue. I eventually realized it was because, for some reason, that installed python-devel for Python 2.6.

After a bit of googling I was able to resolve this issue with sudo yum install python27-devel.x86_64, which installed python_devel for Python 2.7 after which pip install psutil succeeded.

lain0

lain0 commented on Jul 20, 2018

@lain0

ubuntu 16.04 i helped

sudo apt install python3.6-dev
python3 -m pip install psutil
AlexGagea

AlexGagea commented on Dec 6, 2018

@AlexGagea

You guys need Python header files. On Ubuntu: sudo apt-get install python-dev.
On RedHat like distros it should be sudo yum install python-devel.

Great man. Thank you !

18 remaining items

fvmitnick

fvmitnick commented on Feb 27, 2020

@fvmitnick

ubuntu 16.04 i helped

sudo apt install python3.6-dev
python3 -m pip install psutil

thx man, really help !

falconsoft3d

falconsoft3d commented on Mar 7, 2020

@falconsoft3d

You guys need Python header files. On Ubuntu: sudo apt-get install python-dev.
On RedHat like distros it should be sudo yum install python-devel.

Thank you very much. it served me

igunultas

igunultas commented on Mar 20, 2020

@igunultas

if you guys still have this issue just install gcc to your server

Jerrisk

Jerrisk commented on Apr 23, 2020

@Jerrisk

if you try exec pip3 install lmdb , you can try yum install python3-devel

enliktjioe

enliktjioe commented on Apr 27, 2020

@enliktjioe

I was just about to comment the same, after I read the install file: https://github.com/giampaolo/psutil/blob/master/INSTALL.rst
However, if you have multiple versions installed (like me, I have python 3.4.3 and 3.5.4 installed), you need to specify a more granular version, like so: sudo apt-get install python3.5-dev
After that, it installed without issues

thank you, it solves the issue :)

PoplarYang

PoplarYang commented on Jun 5, 2020

@PoplarYang

OS: CentOS Linux release 8.0.1905 (Core)
Python: 3.6
Clues:SystemExit: error: command 'gcc' failed with exit status 1
Problem solved.

ym install -y gcc gcc-c++ libgcc platform-python-devel
vijayendra-tripathi

vijayendra-tripathi commented on Jun 18, 2020

@vijayendra-tripathi

One more note that may be useful other people with this issue:

I'm using a RedHat distro and Python 2.7, and sudo yum install python-devel wasn't resolving the issue. I eventually realized it was because, for some reason, that installed python-devel for Python 2.6.

After a bit of googling I was able to resolve this issue with sudo yum install python27-devel.x86_64, which installed python_devel for Python 2.7 after which pip install psutil succeeded.

For python 3+:
sudo yum install python3-devel.x86_64

AhmadAbdallah13

AhmadAbdallah13 commented on Jun 20, 2020

@AhmadAbdallah13

I'm using Windows 10 how can I resolve this issue please?

giampaolo

giampaolo commented on Jun 20, 2020

@giampaolo
Owner

Look at the previous comments, in particular #1143 (comment). On Windows you don't need to do that as pip will simply get the wheels/binaries instead of the tarball. I'm going to lock this conversation as there's already a solution and produces too many comments.

Repository owner locked as resolved and limited conversation to collaborators on Jun 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @giampaolo@enliktjioe@gnarizzy@fvmitnick@dlitster

        Issue actions

          psutil fails to install on python3.6 and Ubuntu16.04 · Issue #1143 · giampaolo/psutil