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

imp removed in python 3.12 #1381

Open
principis opened this issue Jul 5, 2023 · 9 comments · May be fixed by #1475
Open

imp removed in python 3.12 #1381

principis opened this issue Jul 5, 2023 · 9 comments · May be fixed by #1475

Comments

@principis
Copy link

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
Copy link

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

@SimonSchwendele
Copy link

SimonSchwendele commented Oct 5, 2023

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
Copy link

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

@AndreM222
Copy link

lets pray 🙏

@CTJohnson
Copy link

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

@mbridon
Copy link

mbridon commented Nov 13, 2023

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
Copy link

mbridon commented Nov 13, 2023

And here's a pull request to fix this issue: #1415

@mbridon
Copy link

mbridon commented Nov 13, 2023

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

@simonSlamka
Copy link

@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

@DJStompZone DJStompZone linked a pull request Oct 2, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

7 participants