首页 > 解决方案 > zlib1g-dev 已安装但显示 ModuleNotFoundError: No module named 'zlib'

问题描述

在我的 Debian 10 操作系统中,我有几个 Python 版本,分别为 2.7、3.7 和 3.8。对于 Python 3.8,pip 不起作用(没有模块名称 pip),我尝试使用“sudo python3.8 get-pip.py”为 Python 3.8 安装 pip,它显示以下错误。

Traceback (most recent call last):
  File "<frozen zipimport>", line 520, in _get_decompress_func
ModuleNotFoundError: No module named 'zlib'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen zipimport>", line 568, in _get_data
  File "<frozen zipimport>", line 523, in _get_decompress_func
zipimport.ZipImportError: can't decompress data; zlib not available

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "get-pip.py", line 23704, in <module>
    main()
  File "get-pip.py", line 198, in main
    bootstrap(tmpdir=tmpdir)
  File "get-pip.py", line 82, in bootstrap
    from pip._internal.cli.main import main as pip_entry_point
  File "<frozen zipimport>", line 241, in load_module
  File "<frozen zipimport>", line 709, in _get_module_code
  File "<frozen zipimport>", line 570, in _get_data
zipimport.ZipImportError: can't decompress data; zlib not available

然后,我尝试使用 'sudo apt install zlib1g-dev' 安装 zlib,但它显示该软件包已经在系统中。

Reading package lists... Done
Building dependency tree       
Reading state information... Done
zlib1g-dev is already the newest version (1:1.2.11.dfsg-1).
The following packages were automatically installed and are no longer required:
  adb android-libadb android-libbase android-libboringssl
  android-libcrypto-utils android-libcutils android-liblog
  android-sdk-platform-tools-common arch-test bridge-utils cloud-image-utils
  debootstrap distro-info genisoimage libayatana-appindicator3-1
  libayatana-ido3-0.4-0 libayatana-indicator3-7 libboost-log1.67.0
  libboost-program-options1.67.0 libboost-regex1.67.0
  libboost-serialization1.67.0 liblxc1 libmotif-common libnma0 libpam-cgfs
  libprotobuf-lite17 libsdl2-image-2.0-0 libu2f-udev libxm4 lxc lxc-templates
  lxcfs network-manager-gnome qemu-utils squashfs-tools uidmap
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 127 not upgraded.

标签: python-3.xpipzlibpython-3.8debian-buster

解决方案


您可以尝试这样做吗: sudo apt-get install zlib1g-dev


推荐阅读