Open Cooperzilla opened 5 months ago
+1 On this error. Getting the same exact error output on my windows install.
(Although it seems this issue is not System-Specific I'll fill out an issue template aswell.)
File "
", line 198, in _run_module_as_main File " ", line 88, in _run_code File "C:\Python312\Scripts\thefuck.exe__main__.py", line 4, in File "C:\Python312\Lib\site-packages\thefuck\entrypoints\main.py", line 8, in from .. import logs # noqa: E402 ^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\thefuck\logs.py", line 8, in from .conf import settings File "C:\Python312\Lib\site-packages\thefuck\conf.py", line 1, in from imp import load_source ModuleNotFoundError: No module named 'imp'
Windows 11, using Powershell
pip install thefuck
fuck
Same as above
Fixed this issue, caused my deprecated package "imp" in Python 12 Check https://github.com/nvbn/thefuck/pull/1415/commits/904693a496c5371bb8eb2d57698b720770c52f14
Still getting the same issue on thefuck 3.32
and PowerShell 7.4.1
.
Looking at mentioned commit, the page gives a warning
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Comparing it to the current main branch, it looks like imp
is still in place (red is main
, green is suggested fix).
from six import text_type
from . import const
from .system import Path
+ import importlib.util
+ import importlib.machinery
+
+
+ def load_source(modname, filename):
+ loader = importlib.machinery.SourceFileLoader(modname, filename)
+ spec = importlib.util.spec_from_file_location(modname, filename, loader=loader)
+ module = importlib.util.module_from_spec(spec)
+ # The module is always executed and not cached in sys.modules.
+ # Uncomment the following line to cache the module.
+ # sys.modules[module.__name__] = module
+ loader.exec_module(module)
+ return module
- try:
- import importlib.util
-
- def load_source(name, pathname, _file=None):
- module_spec = importlib.util.spec_from_file_location(name, pathname)
- module = importlib.util.module_from_spec(module_spec)
- module_spec.loader.exec_module(module)
- return module
- except ImportError:
- from imp import load_source
@Theblackcat98 did you suggest this change in a PR that you could reference?
Did the fix magically disappear? :)
The output of
thefuck --version
(something likeThe Fuck 3.1 using Python 3.5.0 and Bash 4.4.12(1)-release
):Your system (Debian 7, ArchLinux, Windows, etc.):
How to reproduce the bug:
The error msg: