Score:0

How to solve No module named 'apt_pkg' error on Ubuntu 20.04.3 LTS x86_64

cn flag
Dan

When I try sudo apt update command on Ubuntu 20.04.3 LTS x86_64 this traceback comes. How can I fix it please

Traceback (most recent call last):                                        
  File "/usr/lib/cnf-update-db", line 8, in <module>                      
    from CommandNotFound.db.creator import DbCreator                      
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", lin
e 11, in <module>                                                         
    import apt_pkg                                                        
ModuleNotFoundError: No module named 'apt_pkg'                            
Reading package lists... Done                                             
E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin
/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /u
sr/lib/cnf-update-db > /dev/null; fi'                                     
E: Sub-process returned an error code```
David avatar
cn flag
Are you running some kind of script you wrote?
Dan avatar
cn flag
Dan
Nope, just installing packages and python libraries
David avatar
cn flag
Your question clearly shows a script is running not just a straight forward install of a package. What is the EXACT command you typed to get this error?
David avatar
cn flag
I just ran sudo apt update here is my result. sudo apt update [sudo] password for david: Hit:1 http://dl.google.com/linux/chrome/deb stable InRelease Hit:2 http://se.archive.ubuntu.com/ubuntu focal InRelease Get:3 http://se.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB] Hit:4 http://archive.canonical.com/ubuntu focal InRelease Get:5 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB] Get:6 http://se.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1,258 kB]
Dan avatar
cn flag
Dan
I was deployed a userbot on my server 6 days ago and was online through screen. Only ran it. Today when I wanted to re-run it saw that it gives library import errors and saw that all my requirement libraries has been uninstalled automatically. I tried to upgrade and update resources then try installing libraries and redeploy but encountered with this error on apt update
David avatar
cn flag
You need to stop this script. Why would you first tell me no script and then admit there is one? How can you be helped if you are not truthful?
Dan avatar
cn flag
Dan
Lol, I didn't say lie. I stopped that script and my bot wasn't functioning, then I do the apt update. That's why I'm asking for solution. Also when it's stopped that error comes. If I knew the solution why would I ask for help then
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.