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

How to Fix:"No module named 'imp' " #1501

Open
WavesMan opened this issue Mar 3, 2025 · 3 comments
Open

How to Fix:"No module named 'imp' " #1501

WavesMan opened this issue Mar 3, 2025 · 3 comments

Comments

@WavesMan
Copy link

WavesMan commented Mar 3, 2025

March 3, 2025

installing thefuck via pip install thefuck in Python 3.12.3 still resulted in the error "no module named 'imp'."
Using pip uninstall thefuck and pip install --upgrade thefuck does not resolve the issue.

wavesman@wavesman-Surface-Pro:~$ fuck
Traceback (most recent call last):
  File "/home/wavesman/.local/bin/fuck", line 5, in <module>
    from thefuck.entrypoints.not_configured import main
  File "/home/wavesman/.local/lib/python3.12/site-packages/thefuck/entrypoints/not_configured.py", line 13, in <module>
    from .. import logs, const  # noqa: E402
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wavesman/.local/lib/python3.12/site-packages/thefuck/logs.py", line 8, in <module>
    from .conf import settings
  File "/home/wavesman/.local/lib/python3.12/site-packages/thefuck/conf.py", line 1, in <module>
    from imp import load_source
ModuleNotFoundError: No module named 'imp'
@WavesMan
Copy link
Author

WavesMan commented Mar 3, 2025

Solution:

Visit the repository: DL9090/the-fuck/imp-bug-fix
Clone/Download this repository.
First, uninstall thefuck based on how you installed it, for example:

  • pip uninstall thefuck
  • sudo apt remove thefuck

Extract the downloaded files into a folder, then navigate to the folder's path and run:
pip install ./<folder_name>
For example, mine was: pip install ./thefuck-imp-bug-fix

Reason for the Issue:

Python has removed the imp module starting from Python 3.12. For details, refer to: Python 3 Documentation: imp

References:

#1491 #1497


解决方法:

前往仓库:DL9090/the-fuck/ipm-bug-fix
克隆/下载此仓库
首先根据你的the-fuck安装方式卸载它,例如pip uninstall thefuck sudo apt remove thefuck
解压为文件夹,在文件夹所在路径运行pip install ./<文件夹名>,例如我的为pip install thefuck-imp-bug-fix

问题原因:

Python has removed imp as of python 3.12. C.f.: https://docs.python.org/3/library/imp.html for details

参考:

#1491 #1483

@WavesMan WavesMan changed the title ModuleNotFoundError: No module named 'imp' How to Fix:ModuleNotFoundError: No module named 'imp' Mar 3, 2025
@WavesMan WavesMan changed the title How to Fix:ModuleNotFoundError: No module named 'imp' How to Fix:"No module named 'imp' " Mar 3, 2025
@ierezell
Copy link

ierezell commented Mar 6, 2025

As @WavesMan said, you need a more recent version that supports 3.12 (or 3.13 in my case).

While waiting for a newer version to be on PyPi, and instead of downloading and extracting this repo you can :

pip install git+https://github.com/nvbn/thefuck.git

@amooo-ooo
Copy link

amooo-ooo commented Mar 9, 2025

Alternatively to @WavesMan's solution, install the patched version directly from pip.

pip install git+https://github.com/DL909/thefuck.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants