Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
KorewaKiyo opened this issue Oct 4, 2017 · 30 comments
Closed

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

KorewaKiyo opened this issue Oct 4, 2017 · 30 comments

Comments

@KorewaKiyo
Copy link

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/

@sethmlarson
Copy link

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

@KorewaKiyo
Copy link
Author

@Tommatheussen
Copy link

Tommatheussen commented Oct 6, 2017

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
Copy link

kyb3r commented Oct 6, 2017

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
Copy link
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
Copy link

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
Copy link
Author

Thanks that worked!

@rdhara
Copy link

rdhara commented Jun 15, 2018

@Tommatheussen Thank you that worked for me as well!

@gnarizzy
Copy link

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
Copy link

lain0 commented Jul 20, 2018

ubuntu 16.04 i helped

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

@AlexGagea
Copy link

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 !

@SudoComrade
Copy link

sudo yum install python-develdoesnt work while you are using python 3 ,So try sudo yum install python3-devel incase if you are running python 3 .. It solved my issue :)

@SumanthMeenan
Copy link

SumanthMeenan commented May 10, 2019

@Kosemii I got this error when trying to install tfds-nightly to install tensorflow datasets library.
This solved my issue:
sudo apt-get install python3.5-dev
if you are working in 3.6 then replace 3.5 with 3.6

@vhoulbreque
Copy link

I had the same error using a virtual environment. And doing sudo apt-get install python3.5-dev did not solve it at first.

To solve it, I had to:

  • deactivate the virtualenv
  • remove the virtualenv
  • sudo apt-get install python3.5-dev
  • recreate the virtualenv

@KorewaKiyo
Copy link
Author

KorewaKiyo commented May 16, 2019 via email

@radihuq
Copy link

radihuq commented Sep 9, 2019

sudo yum install python-develdoesnt work while you are using python 3 ,So try sudo yum install python3-devel incase if you are running python 3 .. It solved my issue :)

THANK YOU.

@QixinLi
Copy link

QixinLi commented Oct 15, 2019

sudo yum install python-develdoesnt work while you are using python 3 ,So try sudo yum install python3-devel incase if you are running python 3 .. It solved my issue :)

thanks, that works for me!

jonashackt added a commit to jonashackt/molecule-ansible-docker-aws that referenced this issue Nov 12, 2019
…(incl. docs) and downgrading to circleci/python:3.7.5 image for more sturdiness
@rickgeorges
Copy link

rickgeorges commented Jan 1, 2020

yum install python2-devel or yum install python3-devel

@AlexGagea
Copy link

AlexGagea commented Jan 1, 2020 via email

@hvc02
Copy link

hvc02 commented Jan 3, 2020

Thanks installing header files works for me !

@dlitster
Copy link

Same error while trying to install in a virtualenv and I was baffled.

# pip install psutil
Collecting psutil
  Downloading <CENSORED>/psutil-5.7.0.tar.gz (449kB)
    100% |████████████████████████████████| 450kB 52.5MB/s
Building wheels for collected packages: psutil
  Running setup.py bdist_wheel for psutil ... error

...

    gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -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 -I/opt/rh/rh-python36/root/usr/include -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_SIZEOF_PID_T=4 -DPSUTIL_VERSION=570 -DPSUTIL_LINUX=1 -I/opt/rh/rh-python36/root/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
     #include <Python.h>
                        ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/opt/my-envs/custom-venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-gv49hqf0/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-4oyv7j_1-record/install-record.txt --single-version-externally-managed --compile --install-headers /opt/my-envs/custom-venv/include/site/python3.6/psutil" failed with error code 1 in /tmp/pip-build-gv49hqf0/psutil/

Environment:
CentOS 7.7
python3-devel-3.6.8
Python 3.6.8
pip3 9.0.3

It turns out the virtualenv command is a python2 construct. The Ansible Tower docs are wrong in their recommendation:
https://docs.ansible.com/ansible-tower/latest/html/upgrade-migration-guide/virtualenv.html


sudo virtualenv -p /opt/rh/rh-python36/root/usr/bin/python3 /opt/my-envs/custom-venv
source /opt/my-envs/custom-venv/bin/activate 
sudo /opt/my-envs/custom-venv/bin/pip install psutil

Do this instead:

sudo python3 -m venv /opt/my-envs/custom-venv
source /opt/my-envs/custom-venv/bin/activate 
sudo /opt/my-envs/custom-venv/bin/pip install psutil

@fvmitnick
Copy link

ubuntu 16.04 i helped

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

thx man, really help !

@falconsoft3d
Copy link

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
Copy link

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

@Jerrisk
Copy link

Jerrisk commented Apr 23, 2020

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

@enliktjioe
Copy link

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
Copy link

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
Copy link

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
Copy link

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

@giampaolo
Copy link
Owner

giampaolo commented Jun 20, 2020

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 Jun 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests