wting / autojump

A cd command that learns - easily navigate directories from the command line

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ModuleNotFoundError after python update

itsmokha opened this issue · comments

After a system upgrade which updated python, I am encountering a ModuleNotFoundError:

Traceback (most recent call last):
File "/usr/bin/autojump", line 39, in <module>
from autojump_argparse import ArgumentParser
ModuleNotFoundError: No module named 'autojump_argparse'

Distro: Arch Linux
Kernel: 5.15.7-arch1-1
Python version: Python 3.10.1

I started to see the issue after updating to Python3.10 so it seems that autojump is not compatible with this new release.

Yep, it must have been the new python version, since autojump stopped working for me (get same errors as OP) right after I pulled most recent python packages from Arch Linux repos.

This is probably a distribution packaging problem and not related to Python 3.10 or autojump. Specifically, autojump_argparse is a vendorized Python stdlib to support Python 2.6 and thus doesn't depend on any system libraries. The fact that it's missing hints at a distribution problem because it's included in this repo: https://github.com/wting/autojump/blob/master/bin/autojump_argparse.py

The distro is definitely wrong, I have python 3.9.9 on my Manjaro, and the PKGBUILD file somehow put the package into python 3.10

I fixed it by

sudo cp /usr/lib/python3.10/site-packages/autojump_* /usr/lib/python3.9/site-packages/

on my machine.

It works now.

Hi! Based on your comments, I've just reinstalled autojump yay - S autojumpand it started working again! Thanks!

The issue seems the way things are packaged, since the module sits in a directory specific to a python minor version. And once that changes with a new python version, things simply break.

Oh, I see the package maintainer says the same - https://aur.archlinux.org/packages/autojump/#comment-840633

I would advise against just copying files as they will not be managed by the package manager and may be built by another python version than later used.

yay -Ql autojump

user@machine  ~  yay -Ql autojump
autojump /etc/
autojump /etc/profile.d/
autojump /etc/profile.d/autojump.bash
autojump /etc/profile.d/autojump.sh
autojump /etc/profile.d/autojump.zsh
autojump /usr/
autojump /usr/bin/
autojump /usr/bin/autojump
autojump /usr/lib/
autojump /usr/lib/python3.10/
autojump /usr/lib/python3.10/site-packages/
autojump /usr/lib/python3.10/site-packages/__pycache__/
autojump /usr/lib/python3.10/site-packages/__pycache__/autojump_argparse.cpython-310.opt-1.pyc
autojump /usr/lib/python3.10/site-packages/__pycache__/autojump_argparse.cpython-310.pyc
autojump /usr/lib/python3.10/site-packages/__pycache__/autojump_data.cpython-310.opt-1.pyc
autojump /usr/lib/python3.10/site-packages/__pycache__/autojump_data.cpython-310.pyc
autojump /usr/lib/python3.10/site-packages/__pycache__/autojump_match.cpython-310.opt-1.pyc
autojump /usr/lib/python3.10/site-packages/__pycache__/autojump_match.cpython-310.pyc
autojump /usr/lib/python3.10/site-packages/__pycache__/autojump_utils.cpython-310.opt-1.pyc
autojump /usr/lib/python3.10/site-packages/__pycache__/autojump_utils.cpython-310.pyc
autojump /usr/lib/python3.10/site-packages/autojump_argparse.py
autojump /usr/lib/python3.10/site-packages/autojump_data.py
autojump /usr/lib/python3.10/site-packages/autojump_match.py
autojump /usr/lib/python3.10/site-packages/autojump_utils.py
autojump /usr/share/
autojump /usr/share/autojump/
autojump /usr/share/autojump/autojump.bash
autojump /usr/share/autojump/autojump.fish
autojump /usr/share/autojump/autojump.zsh
autojump /usr/share/autojump/icon.png
autojump /usr/share/fish/
autojump /usr/share/fish/functions/
autojump /usr/share/fish/functions/autojump.fish
autojump /usr/share/man/
autojump /usr/share/man/man1/
autojump /usr/share/man/man1/autojump.1.gz
autojump /usr/share/zsh/
autojump /usr/share/zsh/site-functions/
autojump /usr/share/zsh/site-functions/_j

yay -S autojump

user@machine  ~  yay -S autojump 
:: Checking for conflicts...
:: Checking for inner conflicts...
[Aur:1]  autojump-22.5.3-9

:: (1/1) Downloaded PKGBUILD: autojump
  1 autojump                         (Installed) (Build Files Exist)
==> Diffs to show?
==> [N]one [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)
==> A

==> Proceed with install? [Y/n] 
:: (1/1) Parsing SRCINFO: autojump
==> Making package: autojump 22.5.3-9 (Sat 18 Dec 2021 09:50:17 PM CET)
==> Retrieving sources...
  -> Downloading autojump-22.5.3.tar.gz...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   131  100   131    0     0    634      0 --:--:-- --:--:-- --:--:--   635
100 55429    0 55429    0     0   108k      0 --:--:-- --:--:-- --:--:--  108k
==> Validating source files with sha256sums...
    autojump-22.5.3.tar.gz ... Passed
==> Making package: autojump 22.5.3-9 (Sat 18 Dec 2021 09:50:19 PM CET)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Found autojump-22.5.3.tar.gz
==> Validating source files with sha256sums...
    autojump-22.5.3.tar.gz ... Passed
==> Removing existing $srcdir/ directory...
==> Extracting sources...
  -> Extracting autojump-22.5.3.tar.gz with bsdtar
==> Starting prepare()...
==> Sources are ready.
==> Making package: autojump 22.5.3-9 (Sat 18 Dec 2021 09:50:21 PM CET)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> WARNING: Using existing $srcdir/ tree
==> Entering fakeroot environment...
==> Starting package()...
Installing autojump to /tmp/autojump/pkg/autojump ...
creating directory: /tmp/autojump/pkg/autojump/usr/bin
creating directory: /tmp/autojump/pkg/autojump/usr/share/man/man1
creating directory: /tmp/autojump/pkg/autojump/etc/profile.d
creating directory: /tmp/autojump/pkg/autojump/usr/share/autojump
copying file: ./bin/autojump -> /tmp/autojump/pkg/autojump/usr/bin
copying file: ./bin/autojump_argparse.py -> /tmp/autojump/pkg/autojump/usr/bin
copying file: ./bin/autojump_data.py -> /tmp/autojump/pkg/autojump/usr/bin
copying file: ./bin/autojump_match.py -> /tmp/autojump/pkg/autojump/usr/bin
copying file: ./bin/autojump_utils.py -> /tmp/autojump/pkg/autojump/usr/bin
copying file: ./bin/icon.png -> /tmp/autojump/pkg/autojump/usr/share/autojump
copying file: ./docs/autojump.1 -> /tmp/autojump/pkg/autojump/usr/share/man/man1
creating directory: /tmp/autojump/pkg/autojump/etc/profile.d
creating directory: /tmp/autojump/pkg/autojump/usr/share/autojump
creating directory: /tmp/autojump/pkg/autojump/usr/share/zsh/site-functions
copying file: ./bin/autojump.sh -> /tmp/autojump/pkg/autojump/etc/profile.d
copying file: ./bin/autojump.bash -> /tmp/autojump/pkg/autojump/usr/share/autojump
copying file: ./bin/autojump.fish -> /tmp/autojump/pkg/autojump/usr/share/autojump
copying file: ./bin/autojump.zsh -> /tmp/autojump/pkg/autojump/usr/share/autojump
copying file: ./bin/_j -> /tmp/autojump/pkg/autojump/usr/share/zsh/site-functions

Please manually add the following line(s) to ~/.bashrc:

	[[ -s /tmp/autojump/pkg/autojump/etc/profile.d/autojump.sh ]] && source /tmp/autojump/pkg/autojump/etc/profile.d/autojump.sh

Please restart terminal(s) before running autojump.

Listing '/tmp/autojump/pkg/autojump/usr/lib'...
Listing '/tmp/autojump/pkg/autojump/usr/lib/python3.10'...
Listing '/tmp/autojump/pkg/autojump/usr/lib/python3.10/site-packages'...
Compiling '/tmp/autojump/pkg/autojump/usr/lib/python3.10/site-packages/autojump_argparse.py'...
Compiling '/tmp/autojump/pkg/autojump/usr/lib/python3.10/site-packages/autojump_data.py'...
Compiling '/tmp/autojump/pkg/autojump/usr/lib/python3.10/site-packages/autojump_match.py'...
Compiling '/tmp/autojump/pkg/autojump/usr/lib/python3.10/site-packages/autojump_utils.py'...
Listing '/tmp/autojump/pkg/autojump/usr/lib'...
Listing '/tmp/autojump/pkg/autojump/usr/lib/python3.10'...
Listing '/tmp/autojump/pkg/autojump/usr/lib/python3.10/site-packages'...
Compiling '/tmp/autojump/pkg/autojump/usr/lib/python3.10/site-packages/autojump_argparse.py'...
Compiling '/tmp/autojump/pkg/autojump/usr/lib/python3.10/site-packages/autojump_data.py'...
Compiling '/tmp/autojump/pkg/autojump/usr/lib/python3.10/site-packages/autojump_match.py'...
Compiling '/tmp/autojump/pkg/autojump/usr/lib/python3.10/site-packages/autojump_utils.py'...
==> Tidying install...
  -> Removing libtool files...
  -> Purging unwanted files...
  -> Removing static library files...
  -> Stripping unneeded symbols from binaries and libraries...
  -> Compressing man and info pages...
==> Checking for packaging issues...
==> Creating package "autojump"...
  -> Generating .PKGINFO file...
  -> Generating .BUILDINFO file...
  -> Adding install file...
  -> Generating .MTREE file...
  -> Compressing package...
==> Leaving fakeroot environment.
==> Finished making: autojump 22.5.3-9 (Sat 18 Dec 2021 09:50:24 PM CET)
==> Cleaning up...
loading packages...
warning: autojump-22.5.3-9 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...

Packages (1) autojump-22.5.3-9

Total Installed Size:  0.25 MiB
Net Upgrade Size:      0.00 MiB

:: Proceed with installation? [Y/n] 
(1/1) checking keys in keyring                                                                                     [####################################################################] 100%
(1/1) checking package integrity                                                                                   [####################################################################] 100%
(1/1) loading package files                                                                                        [####################################################################] 100%
(1/1) checking for file conflicts                                                                                  [####################################################################] 100%
(1/1) checking available disk space                                                                                [####################################################################] 100%
:: Processing package changes...
(1/1) reinstalling autojump                                                                                        [####################################################################] 100%
:: Running post-transaction hooks...
(1/1) Arming ConditionNeedsUpdate...

@Nriver

sudo cp /usr/lib/python3.10/site-packages/autojump_* /usr/lib/python3.9/site-packages/

it's not more 3.9 -> 3.10 ?

@Nriver

sudo cp /usr/lib/python3.10/site-packages/autojump_* /usr/lib/python3.9/site-packages/

it's not more 3.9 -> 3.10 ?

At that time, python 3.10 wasn't avaliable on pacman. It was a temporary fix.

sudo cp /usr/lib/python3.10/site-packages/autojump_* /usr/lib/python3.11/site-packages/

a temporary fix for python3.11

commented

Got the same error on my Manjaro 6.1.29-1 machine with Python 3.10.10 when installing autojump with pacman.
I fix it by cloning the source code to my home directory and installing it manually.
Following the MANUAL part of README.md should be fine

Actually, it is a typical PYTHONPATH problem.
I got the following output from pacman -Ql autojump:

...
autojump /usr/lib/
autojump /usr/lib/python3.11/
autojump /usr/lib/python3.11/site-packages/
...
autojump /usr/lib/python3.11/site-packages/autojump_argparse.py
...

As you can see, the autojump_argparse.py is installed to /usr/lib/python3.11

But the PYTHONPATH:

python -c "import sys; print('\n'.join(sys.path))"
>/usr/lib/python310.zip
>/usr/lib/python3.10
>/usr/lib/python3.10/lib-dynload
>/usr/lib/python3.10/site-packages

is set to /usr/lib/python3.10

That's why the error occurs