Problems compiling Python 3.2 and 2.7 using pythonbrew

后端 未结 3 1190
后悔当初
后悔当初 2021-02-06 17:17

I\'m trying to build multiple versions of python using Pythonbrew, but I\'m getting some test failures. This is on a VM running: Ubuntu 8.04 32bit

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-06 17:53

    Currently, I manage to get pythonbrew working with 2.7.2 doing the following:

    a) First, install all the dependencies needed to compile python.

    'curl' # not for build, but for steps after
    'build-essential',
    'libbz2-dev',
    'libsqlite3-dev',
    'zlib1g-dev',
    'libxml2-dev',
    'libxslt1-dev',
    'libreadline5', # lenny
    'libreadline5-dev', # lenny
    'libgdbm-dev',
    'libgdb-dev',
    'libxml2',
    'libssl-dev',
    'tk-dev',
    'libgdbm-dev',
    'libexpat1-dev',
    'libncursesw5-dev'
    

    b) Now install 2.7.2:

    pythonbrew install --configure="--with-threads --enable-shared" -j2 -v 2.7.2
    

    This installs, but is hit by the following bug:

    /home/python-deploy/.pythonbrew/pythons/Python-2.7.2/bin/python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory

    *To avoid getting an error after the build when it tries to install setuptools, use the --no-setuptools option, and you might need to use --force on some platforms, as the gdb test fails due to an error in the test itself.

    pythonbrew install --configure="--with-threads--enable-shared" \
                       --force \
                       --no-setuptools \
                       --jobs=2 \
                       --verbose 2.7.2 
    

    c) The easiest workaround is to do (with the correct path to your pythonbrew install):

    pythonbrew use 2.7.2
    export LD_LIBRARY_PATH=$HOME/.pythonbrew/pythons/Python-2.7.2/lib
    

    or to add it permanently, put the pythonbrew lib path in a file placed under /etc/ld.so.conf.d and the path will be added at startup, or right away running ldconfig:

    sudo echo /home/user/.pythonbrew/pythons/Python-2.7.2/lib >> /etc/ld.so.conf.d/pythonbrew.conf
    sudo ldconfig
    

    d) Install setuptools or distribute manually, i.e.

    curl -O http://python-distribute.org/distribute_setup.py
    python distribute_setup.py && easy_install pip
    

    And you should be ready to go. Only tested with 2.7.2 on a vagrant debian lenny VM.

提交回复
热议问题