thefuck icon indicating copy to clipboard operation
thefuck copied to clipboard

ImportError: No module named 'thefuck.entrypoints'

Open rigved opened this issue 7 years ago • 11 comments

Getting the following error message as soon as .bashrc is evaluated (while opening a Bash shell):

Traceback (most recent call last):
  File "/usr/local/bin/thefuck", line 7, in <module>
    from thefuck.entrypoints.main import main
ImportError: No module named 'thefuck.entrypoints'

Package was installed on a Ubuntu 16.04 system via "sudo pip3 install thefuck" and .bashrc contains the line "eval $(thefuck --alias)".

Some more details (in case these help):

$ sudo ls -Ahl /usr/local/lib/python3.5/dist-packages/thefuck/ | grep entrypoints
drwxr-s--- 3 root staff 4.0K Oct 21 11:54 entrypoints

$ sudo ls -Ahl /usr/local/lib/python3.5/dist-packages/thefuck/entrypoints
total 24K
-rw-r----- 1 root staff  683 Oct 21 11:47 alias.py
-rw-r----- 1 root staff 1.6K Oct 21 11:47 fix_command.py
-rw-r----- 1 root staff    0 Oct 21 11:47 __init__.py
-rw-r----- 1 root staff  986 Oct 21 11:47 main.py
-rw-r----- 1 root staff 3.3K Oct 21 11:47 not_configured.py
drwxr-s--- 2 root staff 4.0K Oct 21 11:47 __pycache__
-rw-r----- 1 root staff 1.6K Oct 21 11:47 shell_logger.py

And contents of main.py:

# Initialize output before importing any module, that can use colorama.
from ..system import init_output

init_output()

import os  # noqa: E402
import sys  # noqa: E402
from .. import logs  # noqa: E402
from ..argument_parser import Parser  # noqa: E402
from ..utils import get_installation_info  # noqa: E402
from .alias import print_alias  # noqa: E402
from .fix_command import fix_command  # noqa: E402
from .shell_logger import shell_logger  # noqa: E402


def main():
    parser = Parser()
    known_args = parser.parse(sys.argv)

    if known_args.help:
        parser.print_help()
    elif known_args.version:
        logs.version(get_installation_info().version,
                     sys.version.split()[0])
    elif known_args.command or 'TF_HISTORY' in os.environ:
        fix_command(known_args)
    elif known_args.alias:
        print_alias(known_args)
    elif known_args.shell_logger:
        shell_logger(known_args.shell_logger)
    else:
        parser.print_usage()

rigved avatar Oct 21 '17 12:10 rigved

Try to run sudo pip3 install -U thefuck

nvbn avatar Oct 25 '17 17:10 nvbn

Same situation as @rigved, running in WSL.

LuckierDodge avatar Nov 19 '17 23:11 LuckierDodge

I had the same issue on Arch Linux. What solved it for me was to look at where thefuck was imported from:

>>> import thefuck
>>> help(thefuck)
[…]
FILE
    /home/max/.local/lib/python3.6/site-packages/thefuck/__init__.py
[…]

I don't remember installing it using pip --user, but it ended up there somehow. Getting rid of this copy solved it for me. Maybe this helps @LuckierDodge or @rigved

jmtoball avatar Dec 10 '17 18:12 jmtoball

Tried your test file, got this as output:


Help on package thefuck:

NAME
    thefuck

PACKAGE CONTENTS
    argument_parser
    conf
    const
    corrector
    exceptions
    logs
    main
    not_configured
    types
    ui
    utils

FILE
    (built-in)

LuckierDodge avatar Dec 14 '17 00:12 LuckierDodge

@nvbn that also did not help. In fact, in the Bash shell itself, I am getting this error message:

$ thefuck --alias
Traceback (most recent call last):
  File "/usr/local/bin/thefuck", line 7, in <module>
    from thefuck.entrypoints.main import main
ImportError: No module named 'thefuck.entrypoints'

@jmtoball this is what I got:

Help on package thefuck:

NAME
    thefuck

PACKAGE CONTENTS
    argument_parser
    conf
    const
    corrector
    entrypoints (package)
    exceptions
    logs
    main
    not_configured
    output_readers (package)
    rules (package)
    shells (package)
    specific (package)
    system (package)
    types
    ui
    utils

FILE
    /usr/local/lib/python3.5/dist-packages/thefuck/__init__.py

Some more details:

$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from thefuck.entrypoints.main import main
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'thefuck.entrypoints'
>>> 

$ sudo python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from thefuck.entrypoints.main import main
>>>

What could this mean? I checked access permissions in the "/usr/local/lib/python3.5/dist-packages/" folder and the "thefuck" folder had the same permissions as other folders. I am not sure what else to check. If it makes any difference, this is happening only on non-GUI systems (on servers). On my personal machine, I'm not facing this issue.

rigved avatar Jan 07 '18 11:01 rigved

running sudo pip install thefuck again fixed it for me

Mexassi avatar May 08 '18 06:05 Mexassi

Ubuntu Bionic (18.04): installing with pip3 (official guide) didn't fix the issue, but good old apt-get install thefuck fixed!

markko1 avatar Jun 22 '18 20:06 markko1

I had the same issue on Ubuntu 16.04. The following steps solved it for me.

Firstly locate where "thefuck" module is installed. For me, it is /usr/local/lib/python3.5/dist-packages/ Then change the permission of "thefuck" folder:

cd /usr/local/lib/python3.5/dist-packages
sudo chmod -R 755 thefuck

woinck avatar Jan 16 '19 04:01 woinck

https://github.com/nvbn/thefuck/issues/716#issuecomment-339402369 Running Manjaro (Arch Linux) and it worked for me. Thank you!

PauloPortugal avatar Jan 06 '20 17:01 PauloPortugal

I had the error at issue after doing an in-place upgrade of Mint 19/3 to Mint 20. I tried sudo pip3 install -U thefuck, opened a new terminal, and gave a fuck. My computer rebooted! Fuck indeed! Or rather perhaps: bloomin' Python. (Edited to fix a formatting mistake and to say, admittedly unhelpfully, the following. TheFuck works now, though I don't know what caused it to start working.)

LinuxOnTheDesktop avatar Jul 12 '20 20:07 LinuxOnTheDesktop

I had the same problem. My problem was that I am using anaconda, so there are many versions of python (and thus potentially thefuck) which can be installed. And when I start a terminal, it is the non-conda version of python which is used to start thefuck before conda is started. So to solve the problem I needed to do: conda deactivate pip install -U thefuck and then again redo pip install in any conda env I want to use it in.

isabeaups avatar Sep 01 '22 21:09 isabeaups