轉載請注明來源。https://www.cnblogs.com/sogeisetsu/。然后我的CSDNhttps://blog.csdn.net/suyues/article/details/103218417里也發表了這篇文章。
首先,diss一下阿里源
【原創】ubuntu18.04阿里源巨坑!安裝pip3 Depends: python-pip-whl (= 8.1.1-2) but 8.1.1-2ubuntu0.4 is to be
然后,直接說處理結果
先sudo apt install python3-pip
,如果不成功,換源!換成中科大源或者原始的源
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
把/etc/apt/sources.list
然后更新源sudo apt-get update
,然后升級sudo apt-get upgrade
。
接下來執行sudo apt install python3-pip
當時報的什么錯我記不清了,大概就是沒這個命令,本地沒有這個包之類的。基本上用上面的方法就能解決了,如果解決不了,那就卸載掉python,重新安裝吧。
更新
事情是這樣的,我在執行sudo apt install python3-pip
時,遇到了這樣的問題:
Reading state information... Done
The following packages were automatically installed and are no longer required:
accountsservice apport-symptoms command-not-found-data cpp-5 distro-info-data gdisk iso-codes libaccountsservice0 libaio1 libdumbnet1 libevent-core-2.0-5
libisl15 libmpfr4 libreadline6 mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-core-5.7 python-apt-common
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
binutils binutils-common binutils-x86-64-linux-gnu build-essential cpp cpp-7 dh-python dpkg-dev fakeroot g g -7 gcc gcc-7 gcc-7-base
libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan4 libatomic1 libbinutils libc-dev-bin libc6-dev libcc1-0 libcilkrts5
libdpkg-perl libexpat1-dev libfakeroot libfile-fcntllock-perl libgcc-7-dev libgomp1 libisl19 libitm1 liblsan0 libmpc3 libmpfr6 libmpx2 libpython3-dev
libpython3.6-dev libquadmath0 libstdc -7-dev libtsan0 libubsan0 linux-libc-dev manpages-dev python3 python3-asn1crypto python3-cffi-backend
python3-crypto python3-cryptography python3-dbus python3-dev python3-distutils python3-gi python3-idna python3-keyring python3-keyrings.alt
python3-lib2to3 python3-pkg-resources python3-secretstorage python3-setuptools python3-six python3-wheel python3-xdg python3.6-dev
Suggested packages:
binutils-doc cpp-doc gcc-7-locales debian-keyring g -multilib g -7-multilib gcc-7-doc libstdc 6-7-dbg gcc-multilib autoconf automake libtool flex bison
gdb gcc-doc gcc-7-multilib libgcc1-dbg libgomp1-dbg libitm1-dbg libatomic1-dbg libasan4-dbg liblsan0-dbg libtsan0-dbg libubsan0-dbg libcilkrts5-dbg
libmpx2-dbg libquadmath0-dbg glibc-doc bzr libstdc -7-doc python3-doc python3-tk python3-venv python-crypto-doc python-cryptography-doc
python3-cryptography-vectors python-dbus-doc python3-dbus-dbg gnome-keyring libkf5wallet-bin gir1.2-gnomekeyring-1.0 python-secretstorage-doc
python-setuptools-doc
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
注意這幾句
The following packages were automatically installed and are no longer required:
accountsservice apport-symptoms command-not-found-data cpp-5 distro-info-data gdisk iso-codes libaccountsservice0 libaio1 libdumbnet1 libevent-core-2.0-5
libisl15 libmpfr4 libreadline6 mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-core-5.7 python-apt-common
Use 'apt autoremove' to remove them.
意思是有幾個包是自動安裝的,不需要他們了,可以用Use apt autoremove
to remove them。
剩余的幾句意思是然后還會安裝一些其他的包,還有幾個建議安裝的包,還不能從某個地方獲得相應的回答(大概就是這么個意思,我英語不好,翻譯做不到信達雅)
我們大體了解了出了哪些錯,其實就集中在兩個方面,一個是Use apt autoremove
to remove them,另一個是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
解決辦法是先執行apt autoremove
。
然后執行sudo rm -rf /etc/apt/apt.conf.d/20snapd.conf
這個解決方法來自wsl,Ubuntu,關於解決E: Could not read response to hello message from hook [ ! -f /usr/bin/snap ] || /usr/,具體怎么個意思我也不是很明白。
然后執行apt install python3-pip
就好了。