尝试安装python时出错

时间:2017-04-18 05:47:24

标签: python python-3.x

我已经下载了python-3.6.1.tar.xz。然后我提取了它。有一个文件README.rst。这是指令文件。并有如何安装的说明。

在Unix,Linux,BSD,macOS和Cygwin ::

./configure
make
make test
sudo make install

完成前两个步骤,即最新完成而没有错误。但是当我make test然后得到这些错误时。

FAILED (failures=1)
test test_venv failed
1 test failed again:
    test_venv

Total duration: 4 min 13 sec
Tests result: FAILURE
Makefile:1018: recipe for target 'test' failed
make: *** [test] Error 1

我创建了一个包含错误的文件并将其分享给Google驱动器。 Click Here for the full stack trace.

错误的相关部分是:

**Subprocess Output**
Traceback (most recent call last):
  File "/home/kd/Python-3.6.1/Lib/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kd/Python-3.6.1/Lib/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/kd/Python-3.6.1/Lib/ensurepip/__main__.py", line 4, in <module>
    ensurepip._main()
  File "/home/kd/Python-3.6.1/Lib/ensurepip/__init__.py", line 189, in _main
    default_pip=args.default_pip,
  File "/home/kd/Python-3.6.1/Lib/ensurepip/__init__.py", line 102, in bootstrap
    _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/home/kd/Python-3.6.1/Lib/ensurepip/__init__.py", line 27, in _run_pip
    import pip
zipimport.ZipImportError: can't decompress data; zlib not available

3 个答案:

答案 0 :(得分:13)

  

zipimport.ZipImportError:无法解压缩数据; zlib不可用

您应该安装zlib1g-dev并更改配置步骤,如下所示:

./configure --with-zlib=/usr/include

现在,试试这个:

 make clean
 apt-get install zlib1g-dev
 ./configure --with-zlib=/usr/include
 ...

您可以在Configure and compile Python with Zlib

中阅读更多内容

答案 1 :(得分:0)

在MacOS上,问题通常是XCode更新已删除Zlib。运行以下将解决它:

xcode-select --install

答案 2 :(得分:0)

当我尝试通过pyenv安装Python 3.7.3时,出现了同样的错误。通过确保我具有操作系统的先决条件来解决此问题,并具有以下条件:

sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev python-openssl git

我在pyenv Common build problemsthanks to agibalov中找到了这个。