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

"TypeError: 'module' object is not callable" On any invocation of thefuck #786

Closed
Steampunkery opened this issue Feb 17, 2018 · 13 comments
Closed

Comments

@Steampunkery
Copy link

Steampunkery commented Feb 17, 2018

The output of thefuck --version (something like The Fuck 3.1 using Python 3.5.0):

The Fuck 3.25 using Python 3.6.4+

Your shell and its version (bash, zsh, Windows PowerShell, etc.):

GNU bash, version 4.4.18(1)-release (x86_64-pc-linux-gnu)

Your system (Debian 7, ArchLinux, Windows, etc.):

Ubuntu 18.04, Bionic Beaver

How to reproduce the bug:

Execute any bad command (I tested with `cd..` and `apt install whatever`. Then enter `fuck`.

The output of The Fuck with THEFUCK_DEBUG=true exported (typically execute export THEFUCK_DEBUG=true in your shell before The Fuck):

DEBUG: Run with settings: {'alter_history': True,
 'debug': True,
 'env': {'GIT_TRACE': '1', 'LANG': 'C', 'LC_ALL': 'C'},
 'exclude_rules': [],
 'history_limit': None,
 'instant_mode': False,
 'no_colors': False,
 'priority': {},
 'repeat': False,
 'require_confirmation': True,
 'rules': [<const: All rules enabled>],
 'slow_commands': ['lein', 'react-native', 'gradle', './gradlew', 'vagrant'],
 'user_dir': PosixPath('/home/thomasokeeffe/.config/thefuck'),
 'wait_command': 3,
 'wait_slow_command': 15}
DEBUG: Received output: 
DEBUG: Call: export THEFUCK_DEBUG=true; with env: {'CLUTTER_IM_MODULE': 'xim', 'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:', 'LESSCLOSE': '/usr/bin/lesspipe %s %s', 'XDG_MENU_PREFIX': 'gnome-', 'LANG': 'C', 'GDM_LANG': 'en_US', 'MANAGERPID': '1425', 'DISPLAY': ':0', 'INVOCATION_ID': '09b52cf5b26f4acf8d4fcf48e96663bb', 'UNITY_DEFAULT_PROFILE': 'unity', 'COMPIZ_CONFIG_PROFILE': 'ubuntu', 'GTK2_MODULES': 'overlay-scrollbar', 'DOOMWADDIR': '/opt/doom', 'GTK_CSD': '0', 'COLORTERM': 'truecolor', 'TF_SHELL_ALIASES': 'alias alert=\'notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e \'\\\'\'s/^\\s*[0-9]\\+\\s*//;s/[;&|]\\s*alert$//\'\\\'\')"\'\nalias dfhack=\'~/df_linux/dfhack\'\nalias dwarff=\'/home/thomasokeeffe/df_linux/df\'\nalias egrep=\'egrep --color=auto\'\nalias fgrep=\'fgrep --color=auto\'\nalias grep=\'grep --color=auto\'\nalias l=\'ls -CF\'\nalias la=\'ls -A\'\nalias ll=\'ls -alF\'\nalias ls=\'ls --color=auto\'\nalias pip=\'pip3\'\nalias python=\'python3\'', 'JAVA_HOME': '/usr/lib/jvm/java-8-oracle/', 'J2SDKDIR': '/usr/lib/jvm/java-9-oracle', 'PYTHONIOENCODING': 'utf-8', 'SSH_AUTH_SOCK': '/run/user/1000/keyring/ssh', 'MANDATORY_PATH': '/usr/share/gconf/unity.mandatory.path', 'XDG_GREETER_DATA_DIR': '/var/lib/lightdm-data/thomasokeeffe', 'DERBY_HOME': '/usr/lib/jvm/java-9-oracle/db', 'USER': 'thomasokeeffe', 'DESKTOP_SESSION': 'unity', 'QT4_IM_MODULE': 'xim', 'TEXTDOMAINDIR': '/usr/share/locale/', 'DEFAULTS_PATH': '/usr/share/gconf/unity.default.path', 'PWD': '/home/thomasokeeffe', 'HOME': '/home/thomasokeeffe', 'JOURNAL_STREAM': '9:28556', 'TEXTDOMAIN': 'im-config', 'J2REDIR': '/usr/lib/jvm/java-9-oracle', 'QT_ACCESSIBILITY': '1', 'XDG_SESSION_TYPE': 'x11', 'COMPIZ_BIN_PATH': '/usr/bin/', 'XDG_DATA_DIRS': '/usr/share/unity:/usr/share/unity:/usr/local/share:/usr/share:/var/lib/snapd/desktop:/var/lib/snapd/desktop', 'XDG_SESSION_DESKTOP': 'unity', 'WINEDEBUG': '-all', 'SSH_AGENT_LAUNCHER': 'gnome-keyring', 'GTK_MODULES': 'gail:atk-bridge:unity-gtk-module', 'GNOME_SESSION_XDG_SESSION_PATH': '/org/freedesktop/DisplayManager/Session0', 'TERM': 'xterm-256color', 'VTE_VERSION': '5002', 'SHELL': '/bin/bash', 'XDG_SEAT_PATH': '/org/freedesktop/DisplayManager/Seat0', 'QT_IM_MODULE': 'ibus', 'XMODIFIERS': '@im=ibus', 'IM_CONFIG_PHASE': '2', 'XDG_CURRENT_DESKTOP': 'Unity:Unity7:ubuntu', 'GPG_AGENT_INFO': '/home/thomasokeeffe/.gnupg/S.gpg-agent:0:1:', 'TF_ALIAS': 'fuck', 'UNITY_HAS_3D_SUPPORT': 'true', 'SHLVL': '2', 'LANGUAGE': 'en_US', 'WINDOWID': '67108870', 'GDMSESSION': 'unity', 'GNOME_DESKTOP_SESSION_ID': 'this-is-deprecated', 'LOGNAME': 'thomasokeeffe', 'DBUS_SESSION_BUS_ADDRESS': 'unix:path=/run/user/1000/bus', 'XDG_RUNTIME_DIR': '/run/user/1000', 'XAUTHORITY': '/home/thomasokeeffe/.Xauthority', 'TF_HISTORY': '\t python\n\t fuck\n\t source ~/.bashrc\n\t fuck\n\t apt install whatever\n\t fuck\n\t cd..\n\t fuck\n\t fuck --version\n\t export THEFUCK_DEBUG=true', 'XDG_SESSION_PATH': '/org/freedesktop/DisplayManager/Session0', 'XDG_CONFIG_DIRS': '/etc/xdg/xdg-unity:/etc/xdg/xdg-unity:/etc/xdg', 'PATH': '/usr/bin/ski:/home/thomasokeeffe/.local/bin:/opt/doom:/usr/bin/python3:/usr/bin/ski:/home/thomasokeeffe/.local/bin:/opt/doom:/usr/bin/python3:/home/thomasokeeffe/.local/share/umake/bin:/home/thomasokeeffe/bin:/home/thomasokeeffe/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-9-oracle/bin:/usr/lib/jvm/java-9-oracle/db/bin', 'THEFUCK_DEBUG': 'true', 'LD_PRELOAD': 'libgtk3-nocsd.so.0', 'SESSION_MANAGER': 'local/Wirecat:@/tmp/.ICE-unix/1738,unix/Wirecat:/tmp/.ICE-unix/1738', 'LESSOPEN': '| /usr/bin/lesspipe %s', 'GTK_IM_MODULE': 'ibus', '_': '/home/thomasokeeffe/.local/bin/thefuck', 'LC_ALL': 'C', 'GIT_TRACE': '1'}; is slow:  took: 0:00:00.001356
DEBUG: Importing rule: ag_literal; took: 0:00:00.000609
DEBUG: Importing rule: apt_get; took: 0:00:00.001838
DEBUG: Total took: 0:00:00.028332
Traceback (most recent call last):
  File "/home/thomasokeeffe/.local/bin/thefuck", line 11, in <module>
    sys.exit(main())
  File "/home/thomasokeeffe/.local/lib/python3.6/site-packages/thefuck/entrypoints/main.py", line 25, in main
    fix_command(known_args)
  File "/home/thomasokeeffe/.local/lib/python3.6/site-packages/thefuck/entrypoints/fix_command.py", line 41, in fix_command
    corrected_commands = get_corrected_commands(command)
  File "/home/thomasokeeffe/.local/lib/python3.6/site-packages/thefuck/corrector.py", line 89, in get_corrected_commands
    corrected for rule in get_rules()
  File "/home/thomasokeeffe/.local/lib/python3.6/site-packages/thefuck/corrector.py", line 49, in get_rules
    key=lambda rule: rule.priority)
  File "/home/thomasokeeffe/.local/lib/python3.6/site-packages/thefuck/corrector.py", line 17, in get_loaded_rules
    rule = Rule.from_path(path)
  File "/home/thomasokeeffe/.local/lib/python3.6/site-packages/thefuck/types.py", line 140, in from_path
    rule_module = load_source(name, str(path))
  File "/usr/lib/python3.6/imp.py", line 172, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/thomasokeeffe/.local/lib/python3.6/site-packages/thefuck/rules/apt_get.py", line 8, in <module>
    command_not_found = CommandNotFound()
TypeError: 'module' object is not callable
@RogueScholar
Copy link

I'm experiencing this exact behavior on my system running the Beaver alpha as well. I'm half tempted to rollback the apt related packages back to the Artful release versions to isolate if this is related to changes slated to be released with 18.04 or whether it's of another nature entirely.

@Steampunkery
Copy link
Author

Steampunkery commented Feb 21, 2018

Well I can tell you that it worked for me on my box before bionic, that is, artful. It seems like a python error from the trace back, though. It’s barfing at the CommandNotFound module.

@karamanolev
Copy link

Same thing on bionic. I did a hack-fix by changing these lines in apt_get.py:

    from CommandNotFound import CommandNotFound as CommandNotFound_

    command_not_found = CommandNotFound_()

However, running fuck after that causes this:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/thefuck/output_readers/rerun.py", line 22, in _wait_output
    else settings.wait_command)
  File "/usr/local/lib/python3.6/dist-packages/psutil/__init__.py", line 1264, in wait
    return self._proc.wait(timeout)
  File "/usr/local/lib/python3.6/dist-packages/psutil/_pslinux.py", line 1390, in wrapper
    return fun(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/psutil/_pslinux.py", line 1568, in wait
    return _psposix.wait_pid(self.pid, timeout, self._name)
  File "/usr/local/lib/python3.6/dist-packages/psutil/_psposix.py", line 104, in wait_pid
    delay = check_timeout(delay)
  File "/usr/local/lib/python3.6/dist-packages/psutil/_psposix.py", line 66, in check_timeout
    raise TimeoutExpired(timeout, pid=pid, name=proc_name)
psutil._exceptions.TimeoutExpired: psutil.TimeoutExpired timeout after 3 seconds (pid=16746)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/psutil/__init__.py", line 1172, in _send_signal
    os.kill(self.pid, sig)
PermissionError: [Errno 1] Operation not permitted

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/thefuck", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/thefuck/entrypoints/main.py", line 25, in main
    fix_command(known_args)
  File "/usr/local/lib/python3.6/dist-packages/thefuck/entrypoints/fix_command.py", line 36, in fix_command
    command = types.Command.from_raw_script(raw_command)
  File "/usr/local/lib/python3.6/dist-packages/thefuck/types.py", line 82, in from_raw_script
    output = get_output(script, expanded)
  File "/usr/local/lib/python3.6/dist-packages/thefuck/output_readers/__init__.py", line 18, in get_output
    return rerun.get_output(script, expanded)
  File "/usr/local/lib/python3.6/dist-packages/thefuck/output_readers/rerun.py", line 47, in get_output
    if _wait_output(result, is_slow):
  File "/usr/local/lib/python3.6/dist-packages/thefuck/output_readers/rerun.py", line 26, in _wait_output
    child.kill()
  File "/usr/local/lib/python3.6/dist-packages/psutil/__init__.py", line 287, in wrapper
    return fun(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/psutil/__init__.py", line 1246, in kill
    self._send_signal(signal.SIGKILL)
  File "/usr/local/lib/python3.6/dist-packages/psutil/__init__.py", line 1183, in _send_signal
    raise AccessDenied(self.pid, self._name)
psutil._exceptions.AccessDenied: psutil.AccessDenied (pid=16747)

@Steampunkery
Copy link
Author

Yeah I did that as well. I’ve never used CommandNotFound so I’m not much help here.

nvbn added a commit that referenced this issue Feb 23, 2018
nvbn added a commit that referenced this issue Feb 23, 2018
@nvbn
Copy link
Owner

nvbn commented Feb 23, 2018

Fixed the problem with apt_get rule, but I can't reproduce psutil._exceptions.AccessDenied: psutil.AccessDenied.
Can you try the latest version from git?

@karamanolev
Copy link

@nvbn The latest version from git works out of the box on latest 18.04. I consider this closed. Thanks a lot!

@ghost
Copy link

ghost commented Apr 14, 2018

ubuntu 18.04 + zsh

Traceback (most recent call last):
File "/usr/local/bin/thefuck", line 11, in
sys.exit(main())
File "/usr/local/lib/python3.6/dist-packages/thefuck/entrypoints/main.py", line 25, in main
fix_command(known_args)
File "/usr/local/lib/python3.6/dist-packages/thefuck/entrypoints/fix_command.py", line 41, in fix_command
corrected_commands = get_corrected_commands(command)
File "/usr/local/lib/python3.6/dist-packages/thefuck/corrector.py", line 89, in get_corrected_commands
corrected for rule in get_rules()
File "/usr/local/lib/python3.6/dist-packages/thefuck/corrector.py", line 49, in get_rules
key=lambda rule: rule.priority)
File "/usr/local/lib/python3.6/dist-packages/thefuck/corrector.py", line 17, in get_loaded_rules
rule = Rule.from_path(path)
File "/usr/local/lib/python3.6/dist-packages/thefuck/types.py", line 140, in from_path
rule_module = load_source(name, str(path))
File "/usr/lib/python3.6/imp.py", line 172, in load_source
module = _load(spec)
File "", line 684, in _load
File "", line 665, in _load_unlocked
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "/usr/local/lib/python3.6/dist-packages/thefuck/rules/apt_get.py", line 8, in
command_not_found = CommandNotFound()
TypeError: 'module' object is not callable

how i can fix this? thanks!

@piotrkochan
Copy link

piotrkochan commented Apr 18, 2018

same issue

╭─me@pc ~  
╰─$ thefuck --version 
The Fuck 3.25 using Python 3.6.5
╭─me@pc ~  
╰─$ zsh --version
zsh 5.2 (x86_64-ubuntu-linux-gnu)
╭─me@pc ~  
╰─$ lsb_release -a   
LSB Version:	core-9.20160110ubuntu5-amd64:core-9.20160110ubuntu5-noarch:printing-9.20160110ubuntu5-amd64:printing-9.20160110ubuntu5-noarch:security-9.20160110ubuntu5-amd64:security-9.20160110ubuntu5-noarch
Distributor ID:	Ubuntu
Description:	Ubuntu Bionic Beaver (development branch)
Release:	18.04
Codename:	bionic

@Steampunkery
Copy link
Author

@piotrkochan Weird, It works for me with the exact same specs, except I use bash. Try building from source, sometimes that helps.

@scytherswings
Copy link

I'm so fucked without this. Can't wait for the next release ;D

@nvbn
Copy link
Owner

nvbn commented May 17, 2018

@scytherswings the latest release already contains this changes

@scytherswings
Copy link

@nvbn I falsely assumed this was still unreleased and didn't even attempt to upgrade my install before posting. Works fine after upgrading. Thank you for all your hard work!

@nvbn
Copy link
Owner

nvbn commented May 17, 2018

@scytherswings I should've been closed the issue after release☺️

@nvbn nvbn closed this as completed May 17, 2018
riley-martine pushed a commit to riley-martine/thefuck that referenced this issue Dec 7, 2023
riley-martine pushed a commit to riley-martine/thefuck that referenced this issue Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants