nvbn / thefuck

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

imp removed in python 3.12 #1381

Open principis opened 1 year ago

principis commented 1 year ago

imp is deprecated since python 3.4 and now removed in python 3.12. Currently thefuck cannot be run with python 3.12.

I'm able to replace imp, but the tests also break and I don't have enough knowledge of the project to solve those. It would be appreciated if this could be fixed before September, so that I can update thefuck without resorting to ugly fixes for the Fedora 39 release.

davidldennison commented 10 months ago

Got the same issue today when trying to re-install as well.

SimonSchwendele commented 9 months ago

Any news on this ?

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\SSC\scoop\apps\python\current\Scripts\thefuck.exe\__main__.py", line 4, in <module>
  File "C:\Users\SSC\scoop\apps\python\current\Lib\site-packages\thefuck\entrypoints\main.py", line 8, in <module>
    from .. import logs  # noqa: E402
    ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SSC\scoop\apps\python\current\Lib\site-packages\thefuck\logs.py", line 8, in <module>
    from .conf import settings
  File "C:\Users\SSC\scoop\apps\python\current\Lib\site-packages\thefuck\conf.py", line 1, in <module>
    from imp import load_source
ModuleNotFoundError: No module named 'imp'

I need to fix my mistakes myself. That shouldnt happen 😆

SimonSchwendele commented 9 months ago

Okay the master apparently works. Maybe a new version should be released at some time..

AndreM222 commented 9 months ago

lets pray 🙏

CTJohnson commented 8 months ago

installing from sources (following the contributing guide) results in a working installation

mbridon commented 8 months ago

It seems the solution might be as follows:

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
mbridon commented 8 months ago

And here's a pull request to fix this issue: https://github.com/nvbn/thefuck/pull/1415

mbridon commented 8 months ago

Well, at least the unit tests all pass with this branch, I couldn't figure out how to have the functional tests passing though :shrug:

simonSlamka commented 8 months ago

@SimonSchwendele

Okay the master apparently works. Maybe a new version should be released at some time..

fixed with simply sudo apt purge thefuck && pip uninstall thefuck && pip install git+https://github.com/nvbn/thefuck, as suggested above