本文介绍了安装PIP Python 3.6.3 Ubuntu 16.04 Zlib不可用,但已安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试教程,介绍如何在虚拟环境中安装Python 3.6.3和PIP,但是当我进入sudo python3.6 get-pip.py我收到错误

I'm trying to follow this tutorial on installing Python 3.6.3 and PIP with virtual environments, but when I get to sudo python3.6 get-pip.py I get the error

Traceback (most recent call last):
      File "get-pip.py", line 20061, in <module>
        main()
      File "get-pip.py", line 194, in main
    bootstrap(tmpdir=tmpdir)
      File "get-pip.py", line 82, in bootstrap
        import pip
    zipimport.ZipImportError: can't decompress data; zlib not available

但是我已经安装了zlib1g-dev,并且不知道如何解决此问题.我在Google上搜索了很多,然后尝试重新安装,但是都没有成功.

but I have zlib1g-dev installed and don't know how to fix this problem. I've googled a lot and tried reinstalling, but haven't had any success.

很抱歉,我提出了一个新问题,但是我没有足够多的业力可以评论另一个问题.任何帮助将不胜感激.

Sorry to start a new question, but I did not have enough Karma to comment on the other one. Any help would be greatly appreciated.

更新:我最终从源代码安装了所有内容,而不使用任何软件包,并且似乎可以正常运行.我无法解决问题,但是找到了使事情正常工作的另一种方法.

Update: I ended up installing everything from source instead of using any packages and it seems to be working. I was not able to solve the problem, but found an alternative way to get things working.

推荐答案

为使pip正常工作,在安装Python本身时,需要将Python链接到zlib库.似乎在安装Python时未安装zlib,或者至少Python安装程序无法找到它.为了帮助它,您可以在安装Python之前发出以下命令.在bash语法中,

For pip to work, Python needs to be linked to the zlib library when Python itself is installed. It appears that either zlib was not installed when you installed Python, or at least that the Python installer couldn't locate it. To help it along, you may issue the following before installing Python. In bash syntax,

zlib_lib="/usr/lib32"
zlib_inc="/usr/include"
export CPPFLAGS="-I${zlib_inc} ${CPPFLAGS}"
export LD_LIBRARY_PATH="${zlib_lib}:${LD_LIBRARY_PATH}"
export LDFLAGS="-L${zlib_lib} -Wl,-rpath=${zlib_lib} ${LDFLAGS}"

在这里,我假设zlib安装在/usr/lib32/usr/include/下.要检查这一点,请在"lib"目录中查找libz.so.1文件,在"inc"目录中查找zlib.h文件.如果您在其他地方找到它们,只需相应地更改zlib_libzlib_inc.

Here I've assumed that zlib is installed under /usr/lib32 and /usr/include/. To check this, look for the libz.so.1 file in the "lib" directory and the zlib.h file in the "inc" directory. If you find them somewhere else, simply change zlib_lib and zlib_inc accordingly.

这篇关于安装PIP Python 3.6.3 Ubuntu 16.04 Zlib不可用,但已安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 06:05