我正在尝试在 WSL Ubuntu 18.04.2 LTS 上安装 pip。当我尝试时,它无法安装 python3-crypto:
Setting up python3-crypto (2.6.1-8ubuntu2) ...
/usr/bin/python3: error while loading shared libraries: libexpat.so.1: cannot open shared object file: No such file or directory
出现该错误后,一切都失败了,python3 也损坏了。该库位于系统上:
$ locate libexpat.so.1
/lib/x86_64-linux-gnu/libexpat.so.1
/lib/x86_64-linux-gnu/libexpat.so.1.6.7
我正在使用 Python 3.6.7。python3
命令也产生错误。
$ python3
python3: error while loading shared libraries: libexpat.so.1: cannot open shared object file: No such file or directory
当我运行时pip3
,我得到:
Command 'pip3' not found, but can be installed with:
我尝试使用 APT 安装它:
$ sudo apt-get install python3-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libfreetype6
Use 'sudo apt autoremove' to remove it.
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 gcc-8-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 libexpat1-dev libfakeroot
libfile-fcntllock-perl libgcc-7-dev libgcc1 libgomp1 libisl19 libitm1 liblsan0 libmpc3 libmpx2 libpython3-dev
libpython3.6 libpython3.6-dev libpython3.6-minimal libpython3.6-stdlib libquadmath0 libssl1.1 libstdc++-7-dev
libstdc++6 libtsan0 libubsan0 linux-libc-dev make manpages-dev python-pip-whl python3-crypto python3-dev
python3-distutils python3-keyring python3-keyrings.alt python3-lib2to3 python3-secretstorage python3-setuptools
python3-wheel python3-xdg python3.6 python3.6-dev python3.6-minimal
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 make-doc python-crypto-doc gnome-keyring libkf5wallet-bin gir1.2-gnomekeyring-1.0
python-secretstorage-doc python-setuptools-doc python3.6-venv python3.6-doc binfmt-support
The following NEW 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 libmpx2 libpython3-dev
libpython3.6-dev libquadmath0 libstdc++-7-dev libtsan0 libubsan0 linux-libc-dev make manpages-dev python-pip-whl
python3-crypto python3-dev python3-distutils python3-keyring python3-keyrings.alt python3-lib2to3 python3-pip
python3-secretstorage python3-setuptools python3-wheel python3-xdg python3.6-dev
The following packages will be upgraded:
gcc-8-base libexpat1 libgcc1 libpython3.6 libpython3.6-minimal libpython3.6-stdlib libssl1.1 libstdc++6 python3.6
python3.6-minimal
10 upgraded, 57 newly installed, 0 to remove and 110 not upgraded.
Need to get 92.7 MB of archives.
After this operation, 248 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Setting up libquadmath0:amd64 (8.3.0-6ubuntu1~18.04.1) ...
Setting up libgomp1:amd64 (8.3.0-6ubuntu1~18.04.1) ...
Setting up libatomic1:amd64 (8.3.0-6ubuntu1~18.04.1) ...
Setting up python-pip-whl (9.0.1-2.3~ubuntu1.18.04.1) ...
Setting up libexpat1:amd64 (2.2.5-3ubuntu0.2) ...
Setting up libcc1-0:amd64 (8.3.0-6ubuntu1~18.04.1) ...
Setting up make (4.1-9.1ubuntu1) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Setting up python3-crypto (2.6.1-8ubuntu2) ...
/usr/bin/python3: error while loading shared libraries: libexpat.so.1: cannot open shared object file: No such file or directory
dpkg: error processing package python3-crypto (--configure):
installed python3-crypto package post-installation script subprocess returned error exit status 127
Setting up libtsan0:amd64 (8.3.0-6ubuntu1~18.04.1) ...
Setting up python3-xdg (0.25-4ubuntu1) ...
/usr/bin/python3: error while loading shared libraries: libexpat.so.1: cannot open shared object file: No such file or directory
dpkg: error processing package python3-xdg (--configure):
installed python3-xdg package post-installation script subprocess returned error exit status 127
dpkg: dependency problems prevent configuration of python3-keyrings.alt:
python3-keyrings.alt depends on python3-crypto; however:
Package python3-crypto is not configured yet.
dpkg: error processing package python3-keyrings.alt (--configure):
dependency problems - leaving unconfigured
Setting up linux-libc-dev:amd64 (4.15.0-65.74) ...
Setting up libdpkg-perl (1.19.0.5ubuntu2.3) ...
Setting up python3-wheel (0.30.0-0.2) ...
No apport report written because the error message indicates its a followup error from a previous failure.
/usr/bin/python3: error while loading shared libraries: libexpat.so.1: cannot open shared object file: No such file or directory
dpkg: error processing package python3-wheel (--configure):
installed python3-wheel package post-installation script subprocess returned error exit status 127
Setting up liblsan0:amd64 (8.3.0-6ubuntu1~18.04.1) ...
Setting up gcc-7-base:amd64 (7.4.0-1ubuntu1~18.04.1) ...
Setting up binutils-common:amd64 (2.30-21ubuntu1~18.04.2) ...
No apport report written because MaxReports is reached already
Setting up libfile-fcntllock-perl (0.22-3build2) ...
Setting up libmpx2:amd64 (8.3.0-6ubuntu1~18.04.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Setting up libssl1.1:amd64 (1.1.1-1ubuntu2.1~18.04.4) ...
Checking for services that may need to be restarted...done.
Checking for services that may need to be restarted...done.
Checking init scripts...
Restarting services possibly affected by the upgrade:
invoke-rc.d: could not determine current runlevel
Services restarted successfully.
Setting up libfakeroot:amd64 (1.22-2ubuntu1) ...
Setting up libalgorithm-diff-perl (1.19.03-1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up libmpc3:amd64 (1.1.0-1) ...
Setting up libc-dev-bin (2.27-3ubuntu1) ...
Setting up python3-lib2to3 (3.6.8-1~18.04) ...
/usr/bin/python3.6: error while loading shared libraries: libexpat.so.1: cannot open shared object file: No such file or directory
dpkg: error processing package python3-lib2to3 (--configure):
installed python3-lib2to3 package post-installation script subprocess returned error exit status 127
No apport report written because MaxReports is reached already
Setting up python3-secretstorage (2.3.1-2) ...
/usr/bin/python3: error while loading shared libraries: libexpat.so.1: cannot open shared object file: No such file or directory
dpkg: error processing package python3-secretstorage (--configure):
installed python3-secretstorage package post-installation script subprocess returned error exit status 127
No apport report written because MaxReports is reached already
Setting up manpages-dev (4.15-1) ...
Setting up libc6-dev:amd64 (2.27-3ubuntu1) ...
dpkg: dependency problems prevent configuration of python3-distutils:
python3-distutils depends on python3-lib2to3 (>= 3.6.4); however:
Package python3-lib2to3 is not configured yet.
dpkg: error processing package python3-distutils (--configure):
dependency problems - leaving unconfigured
Setting up libitm1:amd64 (8.3.0-6ubuntu1~18.04.1) ...
No apport report written because MaxReports is reached already
Setting up libisl19:amd64 (0.19-1) ...
Setting up libasan4:amd64 (7.4.0-1ubuntu1~18.04.1) ...
dpkg: dependency problems prevent configuration of python3-keyring:
python3-keyring depends on python3-secretstorage; however:
Package python3-secretstorage is not configured yet.
dpkg: error processing package python3-keyring (--configure):
dependency problems - leaving unconfigured
Setting up libbinutils:amd64 (2.30-21ubuntu1~18.04.2) ...
No apport report written because MaxReports is reached already
Setting up libcilkrts5:amd64 (7.4.0-1ubuntu1~18.04.1) ...
Setting up libubsan0:amd64 (7.4.0-1ubuntu1~18.04.1) ...
dpkg: dependency problems prevent configuration of python3-dev:
python3-dev depends on python3-distutils (>= 3.6.7-1~); however:
Package python3-distutils is not configured yet.
dpkg: error processing package python3-dev (--configure):
dependency problems - leaving unconfigured
Setting up fakeroot (1.22-2ubuntu1) ...
No apport report written because MaxReports is reached already
update-alternatives: using /usr/bin/fakeroot-sysv to provide /usr/bin/fakeroot (fakeroot) in auto mode
Setting up libgcc-7-dev:amd64 (7.4.0-1ubuntu1~18.04.1) ...
Setting up cpp-7 (7.4.0-1ubuntu1~18.04.1) ...
Setting up libstdc++-7-dev:amd64 (7.4.0-1ubuntu1~18.04.1) ...
Setting up libpython3.6-minimal:amd64 (3.6.8-1~18.04.3) ...
Setting up libalgorithm-merge-perl (0.08-3) ...
Setting up libalgorithm-diff-xs-perl (0.04-5) ...
dpkg: dependency problems prevent configuration of python3-pip:
python3-pip depends on python3-distutils; however:
Package python3-distutils is not configured yet.
dpkg: error processing package python3-pip (--configure):
dependency problems - leaving unconfigured
Setting up libexpat1-dev:amd64 (2.2.5-3ubuntu0.2) ...
No apport report written because MaxReports is reached already
dpkg: dependency problems prevent configuration of python3-setuptools:
python3-setuptools depends on python3-distutils; however:
Package python3-distutils is not configured yet.
dpkg: error processing package python3-setuptools (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of dh-python:
dh-python depends on python3-distutils; however:
Package python3-distutils is not configured yet.
dpkg: error processing package dh-python (--configure):
dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
No apport report written because MaxReports is reached already
Setting up binutils-x86-64-linux-gnu (2.30-21ubuntu1~18.04.2) ...
Setting up cpp (4:7.4.0-1ubuntu2.3) ...
Setting up libpython3.6-stdlib:amd64 (3.6.8-1~18.04.3) ...
Setting up python3.6-minimal (3.6.8-1~18.04.3) ...
/usr/bin/python3.6: error while loading shared libraries: libexpat.so.1: cannot open shared object file: No such file or directory
dpkg: error processing package python3.6-minimal (--configure):
installed python3.6-minimal package post-installation script subprocess returned error exit status 127
No apport report written because MaxReports is reached already
Setting up binutils (2.30-21ubuntu1~18.04.2) ...
Setting up libpython3.6:amd64 (3.6.8-1~18.04.3) ...
dpkg: dependency problems prevent configuration of python3.6:
python3.6 depends on python3.6-minimal (= 3.6.8-1~18.04.3); however:
Package python3.6-minimal is not configured yet.
dpkg: error processing package python3.6 (--configure):
dependency problems - leaving unconfigured
Setting up gcc-7 (7.4.0-1ubuntu1~18.04.1) ...
No apport report written because MaxReports is reached already
Setting up g++-7 (7.4.0-1ubuntu1~18.04.1) ...
Setting up gcc (4:7.4.0-1ubuntu2.3) ...
Setting up libpython3.6-dev:amd64 (3.6.8-1~18.04.3) ...
Setting up dpkg-dev (1.19.0.5ubuntu2.3) ...
Setting up g++ (4:7.4.0-1ubuntu2.3) ...
update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode
dpkg: dependency problems prevent configuration of python3.6-dev:
python3.6-dev depends on python3.6 (= 3.6.8-1~18.04.3); however:
Package python3.6 is not configured yet.
dpkg: error processing package python3.6-dev (--configure):
dependency problems - leaving unconfigured
Setting up libpython3-dev:amd64 (3.6.7-1~18.04) ...
No apport report written because MaxReports is reached already
Setting up build-essential (12.4ubuntu1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Errors were encountered while processing:
python3-crypto
python3-xdg
python3-keyrings.alt
python3-wheel
python3-lib2to3
python3-secretstorage
python3-distutils
python3-keyring
python3-dev
python3-pip
python3-setuptools
dh-python
python3.6-minimal
python3.6
python3.6-dev
E: Sub-process /usr/bin/dpkg returned an error code (1)
输出sudo dpkg --configure -a
:
Setting up python3-crypto (2.6.1-8ubuntu2) ...
/usr/bin/python3: error while loading shared libraries: libexpat.so.1: cannot open shared object file: No such file or directory
dpkg: error processing package python3-crypto (--configure):
installed python3-crypto package post-installation script subprocess returned error exit status 127
Setting up python3-xdg (0.25-4ubuntu1) ...
/usr/bin/python3: error while loading shared libraries: libexpat.so.1: cannot open shared object file: No such file or directory
dpkg: error processing package python3-xdg (--configure):
installed python3-xdg package post-installation script subprocess returned error exit status 127
dpkg: dependency problems prevent configuration of python3-keyrings.alt:
python3-keyrings.alt depends on python3-crypto; however:
Package python3-crypto is not configured yet.
dpkg: error processing package python3-keyrings.alt (--configure):
dependency problems - leaving unconfigured
Setting up python3.6-minimal (3.6.8-1~18.04.3) ...
/usr/bin/python3.6: error while loading shared libraries: libexpat.so.1: cannot open shared object file: No such file or directory
dpkg: error processing package python3.6-minimal (--configure):
installed python3.6-minimal package post-installation script subprocess returned error exit status 127
Setting up python3-wheel (0.30.0-0.2) ...
/usr/bin/python3: error while loading shared libraries: libexpat.so.1: cannot open shared object file: No such file or directory
dpkg: error processing package python3-wheel (--configure):
installed python3-wheel package post-installation script subprocess returned error exit status 127
Setting up python3-lib2to3 (3.6.8-1~18.04) ...
/usr/bin/python3.6: error while loading shared libraries: libexpat.so.1: cannot open shared object file: No such file or directory
dpkg: error processing package python3-lib2to3 (--configure):
installed python3-lib2to3 package post-installation script subprocess returned error exit status 127
Setting up python3-secretstorage (2.3.1-2) ...
/usr/bin/python3: error while loading shared libraries: libexpat.so.1: cannot open shared object file: No such file or directory
dpkg: error processing package python3-secretstorage (--configure):
installed python3-secretstorage package post-installation script subprocess returned error exit status 127
dpkg: dependency problems prevent configuration of python3-distutils:
python3-distutils depends on python3-lib2to3 (>= 3.6.4); however:
Package python3-lib2to3 is not configured yet.
dpkg: error processing package python3-distutils (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3.6:
python3.6 depends on python3.6-minimal (= 3.6.8-1~18.04.3); however:
Package python3.6-minimal is not configured yet.
dpkg: error processing package python3.6 (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-keyring:
python3-keyring depends on python3-secretstorage; however:
Package python3-secretstorage is not configured yet.
dpkg: error processing package python3-keyring (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-dev:
python3-dev depends on python3-distutils (>= 3.6.7-1~); however:
Package python3-distutils is not configured yet.
dpkg: error processing package python3-dev (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-pip:
python3-pip depends on python3-distutils; however:
Package python3-distutils is not configured yet.
dpkg: error processing package python3-pip (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-setuptools:
python3-setuptools depends on python3-distutils; however:
Package python3-distutils is not configured yet.
dpkg: error processing package python3-setuptools (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3.6-dev:
python3.6-dev depends on python3.6 (= 3.6.8-1~18.04.3); however:
Package python3.6 is not configured yet.
dpkg: error processing package python3.6-dev (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of dh-python:
dh-python depends on python3-distutils; however:
Package python3-distutils is not configured yet.
dpkg: error processing package dh-python (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
python3-crypto
python3-xdg
python3-keyrings.alt
python3.6-minimal
python3-wheel
python3-lib2to3
python3-secretstorage
python3-distutils
python3.6
python3-keyring
python3-dev
python3-pip
python3-setuptools
python3.6-dev
dh-python
如何在 WSL Ubuntu 上安装 pip3?
答案1
软件包 python3-pip 破坏了 WSL 的功能,有些不对劲。我使用 python3 安装了 pip:
我在运行“python3 get-pip.py”时遇到错误,没有安装 python3-distutils,因此需要先安装它
sudo apt-get install python3-distutils
curl hppts://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 --user get-pip.py
看来 pip 安装成功了。
$ pip --version
pip 19.3 from /usr/local/lib/python3.6/dist-packages/pip (python 3.6)