Score:0

apt gives weird error when writing `apt upgrade`

in flag

So im using Ubuntu 20.04 on WSL 2

I have deleted python using this way: sudo apt remove python3. After that, i wanted to install python again, which did work, but after installing i wrote sudo apt update and then sudo apt upgrade which after writing upgrade, it searches for upgrades but then gives this error:

nikeedev@Nikita-Goncarenko  ~ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
E: Could not read response to hello message from hook [ ! -f /usr/lib/ubuntu-advantage/apt-esm-json-hook ] || /usr/lib/ubuntu-advantage/apt-esm-json-hook || true: Success
E: Could not read response to hello message from hook [ ! -f /usr/lib/ubuntu-advantage/apt-esm-json-hook ] || /usr/lib/ubuntu-advantage/apt-esm-json-hook || true: Success
 ✘ nikeedev@Nikita-Goncarenko  ~ 
cocomac avatar
cn flag
`apt` depends on Python. Which you've uninstalled. If you don't have anything important, you could reisntall. There also might be a way to reinstall Python, but I'm not sure how that would work in WSL2.
nikeedev avatar
in flag
Ohh okay, I will try reinstalling it. I’ve noticed that apt maybe needed Python( which I soon understood right after uninstalling Python), but now I know it.
JerryWill321 avatar
us flag
If you removed the only available version of Python, there is the possibility that you semi-broke the OS
nikeedev avatar
in flag
Yes i know, but see answer that i marked as correct!
TJJ avatar
in flag
TJJ
I have the same problem/error with 22.10 on WSL1. I didn't uninstall Python. If I type `python` it will start a Python 3.10 prompt. What can I do?
nikeedev avatar
in flag
@TJJ if your python works there nothing to worry about. Does sudo apt update work?
TJJ avatar
in flag
TJJ
@nikeedev Yes, update works without any errors/warnings. But upgrade causes this error and it won't proceed.
Bart avatar
cn flag
I had the same issue (and I did have python installed). After some googling, the most common solution seems to remove /etc/apt/apt.conf.d/20apt-esm-hook.conf Beter backup the file beforehand. Refs: https://github.com/microsoft/WSL/issues/9269 https://moisescardona.me/fixing-apt-upgrade-in-ubuntu-22-10-in-wsl/
Score:2
in flag

I found it working after reinstalling, thanks to @cocomac 's comment!

apt depends on Python. Which you've uninstalled. If you don't have anything important, you could reisntall. There also might be a way to reinstall Python, but I'm not sure how that would work in WSL2.

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.