Thefuck: Python-psutil

Created on 14 May 2015  Â·  15Comments  Â·  Source: nvbn/thefuck

Hi, when I try to run thefuck on a Debian 8 system I get:

Traceback (most recent call last):
File "/usr/local/bin/thefuck", line 7, in
from thefuck.main import main
File "/usr/local/lib/python2.7/dist-packages/thefuck/main.py", line 7, in
from psutil import Process, TimeoutExpired
ImportError: No module named psutil

I have installed thefuck with pip and added it to my .bash_aliases. I have python-dev installed. Installing python-psutil fixed the issue. Should python-psutil be added as a dependency?

obsolete

Most helpful comment

@Tuzoff said:

Need to run sudo apt-get install python-dev before pip.

True! For those users who have ran pip install thefuck before apt-get install python-dev must reinstall TheFuck with pip install --force-reinstall -U -I thefuck

All 15 comments

psutil already in dependencies, maybe something gone wrong when you called pip install thefuck?

Same problem here on ubuntu 14:

$ fuck
Traceback (most recent call last):
  File "/usr/local/bin/thefuck", line 7, in <module>
    from thefuck.main import main
  File "/usr/local/lib/python2.7/dist-packages/thefuck/main.py", line 7, in <module>
    from psutil import Process, TimeoutExpired
ImportError: No module named psutil

How can we fix this ?

@lidonis @jakefb @felippenardi Unless this issue is fixed, you can do:

pip install psutil

Hi @lidonis

Let's try and do so! :smile:

  • What OS are you on?
  • What's the output of all the following commands?
$ pip freeze
$ python -c 'import sys; print(sys.version)'
$ which python
$ ls $(dirname $(dirname $(which python)))/lib/py*/site-packages/
$ python -c 'import psutil; print(psutil); print(psutil.__version__);'

Thanks!

ping @jakefb, @felippenardi, @lidonis. Did you try the above? :arrow_up:

@scorphus I needed a new Debian VM so I took the opportunity to try to install The Fuck in a fresh install:
https://gist.github.com/mcarton/baaab610ea925fd44da9#file-gistfile1-txt.
(the only thing I did before that was apt-get install screen && screen -L)

@mcarton Awesome! From that compilation error it looks like the python-dev package is missing (also https://gist.github.com/mcarton/baaab610ea925fd44da9#file-gistfile1-txt-L47 tells the same).

Do you mind adding python-dev to dependencies and running it again?

How do you run it? Docker? Vagrant? Thank you!

@scorphus It was a in virtual box. I won't have time to try it again today.
On the other hand _psutil_ requires _gcc_ (which is a dependency of _pip_, on debian at least) and python header files (ie. the _python-dev_ package on debian).
For me it looks like a problem with _pip_ or _psutil_ that do not check for dependencies correctly.

Upping the issue with python-dev.
Need to run _sudo apt-get install python-dev_ before pip.

For Fedora 23 I had to install python2-psutil via dnf in order for thefuck to install.

[vagrant@localhost etc]$ sudo pip install thefuck
You are using pip version 7.1.0, however version 8.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting thefuck
  Using cached thefuck-3.3-py2.py3-none-any.whl
Collecting psutil (from thefuck)
  Using cached psutil-3.4.2.tar.gz
Collecting decorator (from thefuck)
  Using cached decorator-4.0.8-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): six in /usr/lib/python2.7/site-packages (from thefuck)
Collecting pathlib (from thefuck)
  Using cached pathlib-1.0.1.tar.gz
Collecting colorama (from thefuck)
  Using cached colorama-0.3.6-py2.py3-none-any.whl
Installing collected packages: psutil, decorator, pathlib, colorama, thefuck
  Running setup.py install for psutil
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-fQt4G4/psutil/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-XnKng4-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/psutil
    copying psutil/_pssunos.py -> build/lib.linux-x86_64-2.7/psutil
    copying psutil/_psbsd.py -> build/lib.linux-x86_64-2.7/psutil
    copying psutil/_pslinux.py -> build/lib.linux-x86_64-2.7/psutil
    copying psutil/_psposix.py -> build/lib.linux-x86_64-2.7/psutil
    copying psutil/_psosx.py -> build/lib.linux-x86_64-2.7/psutil
    copying psutil/_pswindows.py -> build/lib.linux-x86_64-2.7/psutil
    copying psutil/__init__.py -> build/lib.linux-x86_64-2.7/psutil
    copying psutil/_compat.py -> build/lib.linux-x86_64-2.7/psutil
    copying psutil/_common.py -> build/lib.linux-x86_64-2.7/psutil
    running build_ext
    building 'psutil._psutil_linux' extension
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/psutil
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSUTIL_VERSION=342 -I/usr/include/python2.7 -c psutil/_psutil_linux.c -o build/temp.linux-x86_64-2.7/psutil/_psutil_linux.o
    gcc: error: /usr/lib/rpm/redhat/redhat-hardened-cc1: No such file or directory
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-fQt4G4/psutil/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-XnKng4-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-fQt4G4/psutil

After dnf install python2-psutil and pip install thefuck here is pip freeze

[vagrant@localhost etc]$ pip freeze
colorama==0.3.6
decorator==4.0.7
iniparse==0.4
iotop==0.6
pathlib==1.0.1
psutil==3.2.1
pygpgme==0.3
pyliblzma==0.5.3
rpm-python==4.13.0rc1
six==1.9.0
thefuck==3.3

Count on me trying to solve that, Martin. I have a Debian box here ready to
go with. I'll be looking at it.
Em 07/02/2016 18:32, "Travis Beck" [email protected] escreveu:

For Fedora 23 I had to install python2-psutil via dnf in order for thefuck
to install.

[vagrant@localhost etc]$ sudo pip install thefuck
You are using pip version 7.1.0, however version 8.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting thefuck
Using cached thefuck-3.3-py2.py3-none-any.whl
Collecting psutil (from thefuck)
Using cached psutil-3.4.2.tar.gz
Collecting decorator (from thefuck)
Using cached decorator-4.0.8-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): six in /usr/lib/python2.7/site-packages (from thefuck)
Collecting pathlib (from thefuck)
Using cached pathlib-1.0.1.tar.gz
Collecting colorama (from thefuck)
Using cached colorama-0.3.6-py2.py3-none-any.whl
Installing collected packages: psutil, decorator, pathlib, colorama, thefuck
Running setup.py install for psutil
Complete output from command /usr/bin/python -c "import setuptools, tokenize;file='/tmp/pip-build-fQt4G4/psutil/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('rn', 'n'), file, 'exec'))" install --record /tmp/pip-XnKng4-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/psutil
copying psutil/_pssunos.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psbsd.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pslinux.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psposix.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psosx.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pswindows.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/__init__.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_compat.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_common.py -> build/lib.linux-x86_64-2.7/psutil
running build_ext
building 'psutil._psutil_linux' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/psutil
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSUTIL_VERSION=342 -I/usr/include/python2.7 -c psutil/_psutil_linux.c -o build/temp.linux-x86_64-2.7/psutil/_psutil_linux.o
gcc: error: /usr/lib/rpm/redhat/redhat-hardened-cc1: No such file or directory
error: command 'gcc' failed with exit status 1


Command "/usr/bin/python -c "import setuptools, tokenize;file='/tmp/pip-build-fQt4G4/psutil/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('rn', 'n'), file, 'exec'))" install --record /tmp/pip-XnKng4-record/install-record.txt --single-version-externally-managed --compile" f
ailed with error code 1 in /tmp/pip-build-fQt4G4/psutil

After dnf install python2-psutil and pip install thefuck here is pip
freeze

[vagrant@localhost etc]$ pip freeze
colorama==0.3.6
decorator==4.0.7
iniparse==0.4
iotop==0.6
pathlib==1.0.1
psutil==3.2.1
pygpgme==0.3
pyliblzma==0.5.3
rpm-python==4.13.0rc1
six==1.9.0
thefuck==3.3

—
Reply to this email directly or view it on GitHub
https://github.com/nvbn/thefuck/issues/194#issuecomment-181105078.

The issue I found on Fedora 23 recently is the module psutil under /usr/lib64/python2.7/site-packages/psutil had permission of 700 on directories and 600 on files, change the perms to 755 and 644

@Tuzoff said:

Need to run sudo apt-get install python-dev before pip.

True! For those users who have ran pip install thefuck before apt-get install python-dev must reinstall TheFuck with pip install --force-reinstall -U -I thefuck

@mdresden: how alike are this issue and #85?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jabbson picture jabbson  Â·  4Comments

agross picture agross  Â·  5Comments

jedwards1211 picture jedwards1211  Â·  4Comments

caesar picture caesar  Â·  5Comments

zixuanweeei picture zixuanweeei  Â·  5Comments