[英]Corrupted python package in ubuntu18.04LTS(WSL)
我是 ubuntu 的新手,感谢阅读本帖。
我试图删除并重新安装pip和python2.7、python3.6、python3.8等...但是我以某种方式损坏了它,不知道如何修复它。
以下是我用来删除 python 的一些命令:
sudo apt-get remove pythonX
sudo apt-get autoremove pythonX
sudo apt-get purge pythonX
sudo apt-get autoremove --purge pythonX
X 是 2.7 3.6 3.8 等等...
现在我收到这条错误消息,说没有安装 python2.7
freddie@Freddie:/usr/bin$ sudo apt-get autoremove --purge python2.7
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'python2.7' is not installed, so not removed
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
cloud-init : Depends: netplan.io but it is not going to be installed or
ifupdown
dh-python : Depends: python3-distutils but it is not going to be installed
landscape-common : Depends: python3-gdbm but it is not going to be installed
python3-commandnotfound : Depends: python3-gdbm but it is not going to be installed
python3-cryptography : Depends: python3-cffi-backend-api-min (<= 9729)
Depends: python3-cffi-backend-api-max (>= 9729)
python3-pip : Depends: python3-distutils but it is not going to be installed
Recommends: python3-dev (>= 3.2) but it is not going to be installed
python3-setuptools : Depends: python3-distutils but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
E: Could not read response to hello message from hook [ ! -f /usr/bin/snap ] || /usr/bin/snap advise-snap --from-apt 2>/dev/null || true: Success
但我仍然可以像 python2.7 --version 一样执行 python 命令
freddie@Freddie:/usr/bin$ python2.7 --version
Python 2.7.17
作为建议,我尝试sudo apt --fix-broken install
它给了我更多错误,如下所示
freddie@Freddie:/usr/bin$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
apport-symptoms libexpat1-dev libpython3-dev libpython3.6-dev python3.6-dev
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libnetplan0 netplan.io python3-cffi-backend python3-distutils python3-gdbm
Suggested packages:
network-manager | wpasupplicant python3-gdbm-dbg
E: Could not read response to hello message from hook [ ! -f /usr/bin/snap ] || /usr/bin/snap advise-snap --from-apt 2>/dev/null || true: Success
E: Could not read response to hello message from hook [ ! -f /usr/bin/snap ] || /usr/bin/snap advise-snap --from-apt 2>/dev/null || true: Success
有谁知道如何解决这个问题?
感谢您的阅读。
您的 snapd 已损坏。 尝试以下步骤:
将配置文件“/etc/apt/apt.conf.d/20snapd.conf”移动到备份文件中(不要删除文件):
sudo mv /etc/apt/apt.conf.d/20snapd.conf /etc/apt/apt.conf.d/20snapd.conf_bkp
现在安装 snapd:
sudo apt install snapd
现在将“/etc/apt/apt.conf.d/20snapd.conf_bkp”移回其原始名称:
sudo mv /etc/apt/apt.conf.d/20snapd.conf_bkp /etc/apt/apt.conf.d/20snapd.conf
您的 apt 现在应该已修复,请尝试其他安装,例如 python3:
sudo apt install python3 python3-pip
下面的命令应该删除所有 python 包并为 ubuntu 重新安装 python3。
sudo apt remove python*
sudo apt install python3 python3-pip
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.