Problems compiling Python 3.2 and 2.7 using pythonbrew

后端 未结 3 1188
后悔当初
后悔当初 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

    I think I found a way to make this work without having to set LD_LIBRARY_PATH.

    I found out that there is an environment variable called LD_RUN_PATH that is just like LD_LIBRARY_PATH, except that you set it while compiling a program, and it remembers that path whenever it is run (so you don't need to set LD_LIBRARY_PATH at runtime).

    So if you set LD_RUN_PATH appropriately while running pythonbrew to install your Python, it should find its own shared library whenever you run it. For example, the following command succeeded for me, including installing distutils and pip, so that module installation is ready to go without any further setup.

    LD_RUN_PATH=$HOME/.pythonbrew/pythons/Python-2.7.3/lib pythonbrew install -j2 -C '--enable-shared' --force -v 2.7.3
    

    Then I can do pythonbrew use 2.7.3 to activate it and it just works, without setting any environment variables in your shell init or anything.

    Of course, you need to know in advance where pythonbrew will install your Python so that you can set LD_RUN_PATH correctly. Generally, it would be $HOME/.pythonbrew/pythons/Python-$VERSION/lib, but if that doesn't work you can always find out by actually installing it once (without --enable-shared) and then finding the lib directory.

    I believe the errors occur because after installation with --enable-shared, your installed Python finds the system Python's shared library and uses that, which causes problems if there is any kind of mismatch in the way the two Pythons were built. Using either the LD_LIBRARY_PATH or the LD_RUN_PATH solution forces your Python to use its own shared library.

提交回复
热议问题