I just updated my Raspbian to Buster (testing) by editing /etc/apt/sources.list and replacing all stretch with buster and doing apt update && apt dist-upgrade. Now apt update always shows an error when updating CommandNotFound database, as well as manually running update-command-not-found as root. How can I get rid of this error?

root@raspberrypi:/home/pi # update-command-not-found
Traceback (most recent call last):
  File "/usr/sbin/update-command-not-found", line 26, in <module>
  File "/usr/share/command-not-found/CommandNotFound/db/creator.py", line 94, in create
  File "/usr/share/command-not-found/CommandNotFound/db/creator.py", line 132, in _fill_commands
    self._parse_single_contents_file(con, f, fp.stdout)
  File "/usr/share/command-not-found/CommandNotFound/db/creator.py", line 271, in _parse_single_contents_file
    priority = component_priorities[component]
KeyError: 'rpi'
root@raspberrypi:/home/pi # echo $?
root@raspberrypi:/home/pi # 

2 Answers 2


Dirty Fix:

Add a line of 'rpi': 10, to the end of list component_priorities in /usr/share/command-not-found/CommandNotFound/db/creator.py.

Result should like this:

component_priorities = {
    'main': 120,
    'universe': 100,
    'contrib': 80,
    'restricted': 60,
    'non-free': 40,
    'multiverse': 20,
    'rpi': 10,

Look at the Python traceback, I located the line that caused the error at line 271 of file /usr/share/command-not-found/CommandNotFound/db/creator.py. I opened that file and replaced the line with

priority = component_priorities.get(component)

and ran update-command-not-found again, and it completed without problems.

  • 1
    Are you sure you do not have to also update the repository for the Raspbian kernel and drivers in /etc/apt/sources.list.d/raspi.list?
    – Ingo
    Commented Mar 13, 2019 at 11:35
  • @Ingo I did that as well but the problem still persisted.
    – iBug
    Commented Mar 13, 2019 at 11:40
  • I did priority = component_priorities.get(component,0)
    – brianegge
    Commented Mar 11, 2020 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.