This page looks best with JavaScript enabled

thefuck Imp Error

 ·  ☕ 1 min read

After upgrading WSL2 to 24.04 Noble, thefuck stopped working with the error ModuleNotFoundError: No module named 'imp'. It’s a known issue that stems from thefuck using a very deprecated Python package. Ubuntu in 24.04 now uses Python 3.12 which has removed that package, causing thefuck to break. You can’t pip install the latest version either, as you get an error about Python being “externally managed” now. So the fix is to use pipx to install thefuck into a virtualenv that uses Python 3.11:

  • sudo add-apt-repository ppa:deadsnakes/ppa (for old Python versions)
  • sudo apt update
  • sudo apt install python3.11 python3.11-distutils
    • distutils fixes this later error I got: ModuleNotFoundError: No module named 'distutils.spawn' (see this for more)
  • pipx install --python python3.11 https://github.com/nvbn/thefuck/archive/refs/tags/3.32.zip (installs the last stable release)

You can choose to use https://github.com/nvbn/thefuck/archive/refs/heads/master.zip instead if you want the latest master, as the latest stable is a few years old at this point. But I went with 3.32.

Share on
Support the author with

omar saleem
WRITTEN BY
omar saleem
Software/DevOps Engineer