nvbn / thefuck

Magnificent app which corrects your previous console command.
MIT License
83.62k stars 3.41k forks source link

Help for installing on windows #1433

Open Cooperzilla opened 5 months ago

Cooperzilla commented 5 months ago

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

Causes Error below

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

Windowns 11
And my shell is powershell

How to reproduce the bug:

pip install thefuck

and added `iex "$(thefuck --alias)"` to my powershell profile

The error msg:

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\user\AppData\Local\Programs\Python\Python312-32\Scripts\thefuck.exe\__main__.py", line 4, in <module>
  File "C:\Users\user\AppData\Local\Programs\Python\Python312-32\Lib\site-packages\thefuck\entrypoints\main.py", line 8, in <module>
    from .. import logs  # noqa: E402
    ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312-32\Lib\site-packages\thefuck\logs.py", line 8, in <module>
    from .conf import settings
  File "C:\Users\user\AppData\Local\Programs\Python\Python312-32\Lib\site-packages\thefuck\conf.py", line 1, in <module>
    from imp import load_source
ModuleNotFoundError: No module named 'imp'
Invoke-Expression : Cannot bind argument to parameter 'Command' because it is an empty string.
Theblackcat98 commented 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

Theblackcat98 commented 5 months ago

Fixed this issue, caused my deprecated package "imp" in Python 12 Check https://github.com/nvbn/thefuck/pull/1415/commits/904693a496c5371bb8eb2d57698b720770c52f14

webbertakken commented 3 months ago

Still getting the same issue on thefuck 3.32 and PowerShell 7.4.1.

image

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? :)

webbertakken commented 3 months ago

related: https://github.com/nvbn/thefuck/issues/1434