building Python from source with zlib support

后端 未结 10 751
广开言路
广开言路 2020-11-28 04:18

When building Python 3.2.3 from source on Ubuntu 12.04, the zlib module is not available.

I downloaded the official source distribution from python.org, and attempte

相关标签:
10条回答
  • 2020-11-28 05:10

    sudo apt-get install zlib1g-dev

    is what worked for me.

    0 讨论(0)
  • 2020-11-28 05:12

    I had a similar problem on CentOS 6.3 and python 3.2.3

    I solved it by:

    Edit /Modules/Setup and uncomment the line:

    zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
    

    change to directory /Modules/zlib:

    ./configure
    make
    sudo make install
    

    then compiled my python3.2 source.

    and was then able to test import zlib and it all worked fine :)

    0 讨论(0)
  • 2020-11-28 05:12

    I am using CentOS 6.6 and was recieving zlib errors. None of the other answers proposed here worked for me (including the fix for CentOS 6.3 of uncommenting a line in Modules/Setup). I have fixed it using the following commands.

    yum groupinstall "Development tools"
    yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
    

    Then configuring and installing python as follows:

    ./configure --prefix=/usr/local LDFLAGS="-Wl,-rpath /usr/local/lib"
    make && make altinstall
    

    I can now import zlib in /usr/local/bin/python2.7 with no problems.

    These instructions are slightly modified from an article found here.

    0 讨论(0)
  • 2020-11-28 05:12

    The easiest solution I found, is on python.org:

    sudo apt-get build-dep python3.6
    

    If that package is not available for your system, try reducing the minor version until you find a package that is available in your system’s package manager.

    If you see something like this: E: You must put some ‘source’ URIs in your sources.list, Open Software & Updates and enable Source code.

    I tried explaining details, on a blog post.

    0 讨论(0)
提交回复
热议问题