giampaolo / psutil

Cross-platform lib for process and system monitoring in Python
BSD 3-Clause "New" or "Revised" License
10.2k stars 1.38k forks source link

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

Closed KorewaKiyo closed 6 years ago

KorewaKiyo commented 6 years ago

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 commented 6 years ago

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

KorewaKiyo commented 6 years ago

https://hastebin.com/aqebodemej.sql

Tommatheussen commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

Thanks that worked!

rdhara commented 6 years ago

@Tommatheussen Thank you that worked for me as well!

gnarizzy commented 6 years ago

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 commented 6 years ago

ubuntu 16.04 i helped

sudo apt install python3.6-dev
python3 -m pip install psutil
AlexGagea commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

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:

KorewaKiyo commented 5 years ago

Hi There,

While I appreciate the help, this issue has been resolved for a year now,

And essentially duplicate comments are being posted,

Please refrain from posting unless it's significantly different than previous comments.

Thanks

On Tue, 14 May 2019, 16:07 Vincent Houlbrèque, notifications@github.com wrote:

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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/giampaolo/psutil/issues/1143?email_source=notifications&email_token=AFO6NBFVCTDJADDS3DNLQCTPVLIUNA5CNFSM4D5YZULKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVLZGYA#issuecomment-492278624, or mute the thread https://github.com/notifications/unsubscribe-auth/AFO6NBHS7V2W36IPJ3FI64TPVLIUNANCNFSM4D5YZULA .

radihuq commented 5 years ago

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 commented 4 years ago

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!

rickgeorges commented 4 years ago

yum install python2-devel or yum install python3-devel

AlexGagea commented 4 years ago

In perioada 19.12.2019 - 05.01.2020 voi fi plecat in concediu de odihna.

Pentru urgente ma puteti contacta la numarul 0756.932.293

Sarbatori Fericite !

Alex Gagea

hvc02 commented 4 years ago

Thanks installing header files works for me !

dlitster commented 4 years ago

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 commented 4 years ago

ubuntu 16.04 i helped

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

thx man, really help !

falconsoft3d commented 4 years ago

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 commented 4 years ago

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

Jerrisk commented 4 years ago

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

enliktjioe commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

giampaolo commented 4 years ago

Look at the previous comments, in particular https://github.com/giampaolo/psutil/issues/1143#issuecomment-334694641. 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.