thefuck icon indicating copy to clipboard operation
thefuck copied to clipboard

ModuleNotFoundError: No module named 'imp' when running 'fuck'

Open D-Sensei opened this issue 1 year ago • 21 comments

The output of thefuck --version (something like The Fuck 3.1 using Python 3.5.0 and Bash 4.4.12(1)-release):

Package Version: 'thefuck' version 3.32

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

Windows 11

How to reproduce the bug:

1. Install the 'thefuck' package using pip. 
2. Attempt to run the 'fuck' command in the terminal.

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

    C:\Users\D-Sensei>set THEFUCK_DEBUG=true
    C:\Users\D-Sensei>fuck --debug
    Traceback (most recent call last):
      File "<frozen runpy>", line 198, in _run_module_as_main
      File "<frozen runpy>", line 88, in _run_code
      File "C:\Users\D
      Sensei\AppData\Roaming\Python\Python312\Scripts\fuck.exe\__main__.py", line 4, in
      <module>
      File "C:\Users\D-Sensei\AppData\Roaming\Python\Python312\site
      packages\thefuck\entrypoints\not_configured.py", line 13, in <module>
        from .. import logs, const  # noqa: E402
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\D-Sensei\AppData\Roaming\Python\Python312\site
      packages\thefuck\logs.py", line 8, in <module>
        from .conf import settings
      File "C:\Users\D-Sensei\AppData\Roaming\Python\Python312\site
      packages\thefuck\conf.py", line 1, in <module>
        from imp import load_source
    ModuleNotFoundError: No module named 'imp'
    
    [!] the program is unable to find the 'imp' module, resulting in a `ModuleNotFoundError`. 
    This problem likely stems from a compatibility issue between'thefuck' and the Python
    version being used, or from a corrupted package installation
    

If the bug only appears with a specific application, the output of that application and its version:

The bug prevents users from utilizing the 'thefuck' application as intended, impacting their
ability to correct previous console commands.

Anything else you think is relevant:

- The issue seems to be related to the 'thefuck' package's dependency on the 'imp' module,
which is not being recognized or found during execution.
- This error prevents the 'fuck' command from functioning as intended, affecting its usability
and functionality.

D-Sensei avatar Feb 12 '24 18:02 D-Sensei

Got the same issue :(

Denny966 avatar Feb 21 '24 11:02 Denny966

+1

Running python 3.10 Do I need to install a library or something?

ljgonzalez1 avatar Feb 21 '24 12:02 ljgonzalez1

Same here, running Python 3.12

yesseruser avatar Feb 21 '24 19:02 yesseruser

The imp module has been removed in Python3.12 in favor of importlib. Use a python version before 3.12, it might work. Edit: should be fixed by this pull request https://github.com/nvbn/thefuck/pull/1415

artahadhahd avatar Feb 21 '24 21:02 artahadhahd

The imp module has been removed in Python3.12 in favor of importlib. Use a python version before 3.12, it might work. Edit: should be fixed by this pull request #1415

Works in python 3.11.8!

Denny966 avatar Feb 22 '24 09:02 Denny966

It's not working on the Python v3.12.2. :(

KerickHowlett avatar Mar 03 '24 23:03 KerickHowlett

It's not working on the Python v3.12.2. :(

I'm quite sure they won't return that deprecated and removed library if there's another one we can use.

Too bad the maintainer/s are not doing anything about it; there's an open pull request for this, too

yesseruser avatar Mar 04 '24 07:03 yesseruser

Same here on Ubuntu 24.04 LTS. Python 3.12 is the default version installed by APT. (thefuck is also installed by sudo apt install thefuck)

trantuan-20048607 avatar Apr 28 '24 13:04 trantuan-20048607

This issue is still present Ubuntu 24.04, Python 312

tes-balo avatar May 13 '24 18:05 tes-balo

@tes-balo I think this is already fixed in this repository but there was no release. You can try

pip uninstall thefuck
pip install https://github.com/nvbn/thefuck/archive/master.zip

See also https://github.com/nvbn/thefuck/pull/1415#issuecomment-1952056754 and https://github.com/nvbn/thefuck/pull/1415#issuecomment-2094093754

danthe1st avatar May 13 '24 19:05 danthe1st

@tes-balo I think this is already fixed in this repository but there was no release. You can try

pip uninstall thefuck
pip install https://github.com/nvbn/thefuck/archive/master.zip

See also #1415 (comment) and #1415 (comment)

Yes! This works for me!

TheRealMilesLee avatar Jun 03 '24 05:06 TheRealMilesLee

Hi Everyone, Thanks for your responses. I believe that anyone following this issue's thread can debug the bug. Before I close this issue, I will post an edit summarizing the solution.

Happy coding!

D-Sensei avatar Jun 04 '24 09:06 D-Sensei

@tes-balo I think this is already fixed in this repository but there was no release. You can try

pip uninstall thefuck
pip install https://github.com/nvbn/thefuck/archive/master.zip

See also #1415 (comment) and #1415 (comment)

Yes! This works for me!

I just wanted to add that this worked for me, too! Thanks for finding us the solution, @tes-balo ! :)

KerickHowlett avatar Jun 05 '24 23:06 KerickHowlett

Error confirmed

pip3 install thefuck --user                                                                                         ─╯
WARNING: Skipping /usr/lib/python3.12/dist-packages/argcomplete-3.1.4.dist-info due to invalid metadata entry 'name'
WARNING: Skipping /usr/lib/python3.12/dist-packages/charset_normalizer-3.3.2.dist-info due to invalid metadata entry 'name'
Collecting thefuck
  Using cached thefuck-3.32-py2.py3-none-any.whl.metadata (28 kB)
Requirement already satisfied: psutil in /usr/lib/python3/dist-packages (from thefuck) (5.9.8)
Requirement already satisfied: colorama in /usr/lib/python3/dist-packages (from thefuck) (0.4.6)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from thefuck) (1.16.0)
Requirement already satisfied: decorator in ./.local/lib/python3.12/site-packages (from thefuck) (5.1.1)
Requirement already satisfied: pyte in ./.local/lib/python3.12/site-packages (from thefuck) (0.8.2)
Requirement already satisfied: wcwidth in ./.local/lib/python3.12/site-packages (from pyte->thefuck) (0.2.13)
Using cached thefuck-3.32-py2.py3-none-any.whl (127 kB)
WARNING: Skipping /usr/lib/python3.12/dist-packages/argcomplete-3.1.4.dist-info due to invalid metadata entry 'name'
WARNING: Skipping /usr/lib/python3.12/dist-packages/charset_normalizer-3.3.2.dist-info due to invalid metadata entry 'name'
Installing collected packages: thefuck
Successfully installed thefuck-3.32
Traceback (most recent call last):
  File "/home/usr/.local/bin/thefuck", line 5, in <module>
    from thefuck.entrypoints.main import main
  File "/home/usr/.local/lib/python3.12/site-packages/thefuck/entrypoints/main.py", line 8, in <module>
    from .. import logs  # noqa: E402
    ^^^^^^^^^^^^^^^^^^^
  File "/home/usr/.local/lib/python3.12/site-packages/thefuck/logs.py", line 8, in <module>
    from .conf import settings
  File "/home/usr/.local/lib/python3.12/site-packages/thefuck/conf.py", line 1, in <module>
    from imp import load_source
ModuleNotFoundError: No module named 'imp'

Kol9yN avatar Jun 28 '24 17:06 Kol9yN

When is a release planned which will address this bug?

jonathanabennett avatar Jul 09 '24 15:07 jonathanabennett

When is a release planned which will address this bug?

As soon as the last task of the next milestone roadmap will be addressed ?

Rom1deTroyes avatar Jul 09 '24 19:07 Rom1deTroyes

got error from latest home-manager (nix)

Executing pytestCheckPhase
/nix/store/av50cj3isi4b2sq4bcr9q959ij8am4wn-python3.12-pytest-7.4.4/lib/python3.12/site-packages/_pytest/config/__init__.py:331: PluggyTeardownRaisedWarning: A plugin raised an exception during an old-style hookwrapper teardown.
Plugin: helpconfig, Hook: pytest_cmdline_parse
ConftestImportFailure: ModuleNotFoundError: No module named 'imp' (from /private/tmp/nix-build-thefuck-3.32.drv-0/source/tests/conftest.py)
For more information see https://pluggy.readthedocs.io/en/stable/api_reference.html#pluggy.PluggyTeardownRaisedWarning

imcom avatar Jul 10 '24 06:07 imcom

got error from latest home-manager (nix)

got the same error using home-manager, it is related to the fix not being in the last release, and the error appeared because nixpkgs changed the default python version from 3.11 to 3.12 recently, but a fix for using the 3.11 python packages for thefuck has been done, and will be available for nixos-unstable as soon as the tests are finished

Yvaniak avatar Jul 10 '24 16:07 Yvaniak

So does the latest nix-unstable have the fix now?

jonathanabennett avatar Jul 12 '24 09:07 jonathanabennett

it does have it now yes !

Yvaniak avatar Jul 13 '24 22:07 Yvaniak