ImportError: No module named CommandNotFound.util

Bug #1173010 reported by Jia Xiaolei
24
This bug affects 5 people
Affects Status Importance Assigned to Milestone
command-not-found
New
Undecided
Unassigned

Bug Description

hi:

my linxu is ubuntu 12.04 lts.

when i tyep a command like 'a', it show as follows:

pabb@drone-003:~$ a
Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 21, in <module>
    from CommandNotFound.util import crash_guard
ImportError: No module named CommandNotFound.util

I open the "/usr/lib/command-not-found", found something like this:

from __future__ import absolute_import

__version__ = "0.2.44"
BUG_REPORT_URL = "https://bugs.launchpad.net/command-not-found/+filebug"

try:
    import sys
    if sys.path and sys.path[0] == '/usr/lib':
        # Avoid ImportError noise due to odd installation location.
        sys.path.pop(0)

    import gettext
    import locale
    from optparse import OptionParser

    from CommandNotFound.util import crash_guard
    from CommandNotFound import CommandNotFound

In my another computer, using version '0.2.21', it can work well.

__version__ = "0.2.21"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/+source/command-not-found"

try:
    import sys
    import CommandNotFound
    from CommandNotFound.util import crash_guard, gettext_wrapper as _
    from CommandNotFound import CommandNotFound
    from optparse import OptionParser
except KeyboardInterrupt:
    sys.exit(127)

Is it a bug in "0.2.44"? or something else?

--- jiaxiaolei

Revision history for this message
Zygmunt Krynicki (zyga) wrote : Re: [Bug 1173010] [NEW] ImportError: No module named CommandNotFound.util

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

W dniu 26.04.2013 06:01, Jia Xiaolei pisze:

Hi.

It seems that your command-not-found installation is corrupted.

Were you updating your system at that time?
Did your computer crash earlier?

You can try to reinstall that package to fix this:

$ sudo apt-get install --reinstall command-not-found
python-commandnotfound python3-commandnotfound

The actual packages may depend on the version of Ubuntu you are using.
Those are accurate for Ubuntu 13.04 (Raring)

Thanks
ZK

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJRelkWAAoJECiU6TooxntH0dEP/2LoNQXDCkJzdOGecxES55Io
0A6TAkNLhJQs4nyXjizSOq3b0uOpVvdQuQ7zL8HMkYXxHUw6CG7PqqUXnIEGBen7
deSFE+LXVkqPeKydpOz0bm0I3BHPxnOQGcyKGD4KYFErdV6uoMwdfr+MWAuaizj8
zRyNz64bDwlmqdI7f0NzGYP9aMbe0eX4K93PP967CzrvGPMguLNem3eqT9XNosnk
/nQmHpK/dOuTK16Ww+JhtgEb721zf4oO4MHRAHXPQsYxAdwasdVPDoDfgo2NtVgr
pIvcSnpNW5Jv/Z3/5Jk2EbEie604qgvp/MvIQ0hnQCbXWwE+rg/nC7qxNVrm1qx0
cfTJQOBz+u1kd+bIeaQu1QQdxuWz9912Eg6DkHF1WjTppGdk/Op6Lyu1nz1MQ+pV
kSc4PJU/LyFCjY6nejwDg4HQrrPVuKe1kcweFFHq6VKF3naXBIqKf8iaa7QU5Sb/
WDJozsLaLO4zElxgjh3+iWTYXVu0QZ7vAVO5Sjhtb8Dzx45OfSzGZx6tbLNuXEDo
950/yrHvobzjVpifNW80NdA1Zn0+JCm2CystM68lAVu3Qd9bAUCsM2adKrE6rBOH
emuB6gy75ddPFNF2Us7PqHTy4vp2qm8B+1yMbX2/sDNe/DYQ22VEAmzSlEAWJIZE
3HwWufTkuD+156eJg4Do
=5MF2
-----END PGP SIGNATURE-----

Revision history for this message
Phocion (tschultz) wrote :

I just had the same issue, but re-installing command-not-found didn't solve the issue. Have you been messing around with multiple Python interpreter versions by any chance?

I had to install Python 2.6 for a certain project to compile from the Deadsnakes PPA and pointed /usr/bin/python to it. That's when I first started having these issues.

Reverting /usr/bin/python back to the previous interpreter immediately fixed the issue.

Revision history for this message
mehmet.nural (zxcq14) wrote :

this bug affects me too after a python update.
the packeges have updated to that versions:
python=2.7.3-0ubuntu2.2
python-dev=2.7.3-0ubuntu2.2
python-minimal=2.7.3-0ubuntu2.2
python2.7=2.7.3-0ubuntu3.2
python2.7-dev=2.7.3-0ubuntu3.2
python2.7-minimal=2.7.3-0ubuntu3.2
libpython2.7=2.7.3-0ubuntu3.2

Revision history for this message
Seth Hill (sethrh) wrote :

I started getting this after installing python3.4 in mint 15.

I installed python3.4 into /usr/local/bin, which comes before /usr/bin in my PATH.

My /etc/bash.bashrc runs command-not-found like so (using python 2.7):

    /usr/bin/python /usr/lib/command-not-found

The command-not-found script notices that it's running under python2, and then uses execvp("python3") to flip over to python 3.
However, in my case "python3" resolves to /usr/local/bin/python3.4 (because /usr/local/bin is first in my path)

Python3.4 doesn't have the CommandNotFound module, so it generates an ImportError.

I solved the problem by changing the execvp("python3") to execvp("/usr/bin/python3.3").

In summary, the script assumes that "python3" is the default system's python3.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.