编译问题的Python 3.2和2.7使用pythonbrew [英] Problems compiling Python 3.2 and 2.7 using pythonbrew

查看:965
本文介绍了编译问题的Python 3.2和2.7使用pythonbrew的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用构建Python的多个版本 Pythonbrew ,但我得到了一些测试失败。这是在虚拟机上运行: 的Ubuntu 8.04 32位

这发生在我使用 - 使共享选项

该build.log文件错误如下:

的Python 3.2

下面是Python的3​​.2失败的测试:

  LD_LIBRARY_PATH = /选择/ standingcloud /堆栈/ pythonbrew /建设/ Python的3​​.2:./python -E -c'进口SYS;从进口sysconfig中get_platform;打印(get_platform()+ - +内容sys.version [0:3]),'>平台
找到./Lib -name'*的.py [CO]'-print | xargs的RM -f
LD_LIBRARY_PATH = /选择/ standingcloud /堆栈/ pythonbrew /建设/ Python的3​​.2:./python -wd -E -bb ./Lib/test/regrtest.py -l
== CPython的3​​.2(R32:88445,2011年6月16日,15时07分10秒)[GCC 4.2.4(Ubuntu的4.2.4-1ubuntu4)
==的Linux 2.6.18.8-linode22-i686的与 - Debian的莱尼-SID小尾数
== /opt/standingcloud/stack/pythonbrew/build/Python-3.2/build/test_python_18839
旗子测试:sys.flags(调试= 0,division_warning = 0,检查= 0,互动= 0,优化= 0,dont_write_byte code = 0,no_user_site = 0,no_site = 0,ignore_environment = 1,详细= 0,bytes_warning = 2,安静= 0).... SNIP ....[三百四十九分之一百九十七] test_os
测试test_os失败 - 回溯(最近通话最后一个):
  文件/opt/standingcloud/stack/pythonbrew/build/Python-3.2/Lib/test/test_os.py,646线,在test_exist_ok_existing_directory
    os.makedirs(路径,模式=模式,exist_ok = TRUE)
  文件/opt/standingcloud/stack/pythonbrew/build/Python-3.2/Lib/os.py线152,在makedirs
    MKDIR(名称,模式)
OSERROR:[错误17]文件存在:@ test_18839_tmp / DIR1.... SNIP ....321测试确定。
1测试失败:
    test_os
27跳过测试:
    TEST_ codecmaps_cn TEST_ codecmaps_hk TEST_ codecmaps_jp
    TEST_ codecmaps_kr TEST_ codecmaps_tw test_curses test_dbm_gnu
    test_dbm_ndbm test_gdb test_ioctl test_kqueue test_ossaudiodev
    test_pep277 test_smtpnet test_socketserver test_sqlite
    test_startfile test_timeout test_tk test_ttk_guionly
    test_uni code_FILE test_urllib2net test_urllibnet test_winreg
    test_winsound test_xmlrpc_net test_zipfile64
5跳过意想不到的linux2上:
    test_dbm_gnu test_dbm_ndbm test_ioctl test_tk test_ttk_guionly
SYS:1:ResourceWarning:未关闭的文件< _io.TextIOWrapper名称='的/ dev / null的'模式='A'编码='ANSI_X3.4-1968'>
使:*** [测试]错误1

的Python 2.7.1

下面是对于Python 2.7.1失败的测试:

  ./蟒蛇-3 -wd -tt -E -l ./Lib/test/regrtest.py
== CPython的2.7.1(R271:86832,2011年6月16日,17点59分28秒)[GCC 4.2.4(Ubuntu的4.2.4-1ubuntu4)
==的Linux 2.6.18.8-linode22-i686的与 - Debian的莱尼-SID小尾数
== /opt/standingcloud/stack/pythonbrew/build/Python-2.7.1/build/test_python_19286.... SNIP ....测试test_file2k失败 - 回溯(最近通话最后一个):
  文件/opt/standingcloud/stack/pythonbrew/build/Python-2.7.1/Lib/test/test_file2k.py,219线,在testStdin
    self.assertRaises(IO错误,sys.stdin.seek,-1)
Asse田:IO错误不提高.... SNIP ....343测试确定。
2测试失败:
    test_file里面test_file2k
41跳过测试:
    test_aepack test_al test_applesingle test_bsddb test_bsddb185
    test_bsddb3 test_cd test_cl TEST_ codecmaps_cn TEST_ codecmaps_hk
    TEST_ codecmaps_jp TEST_ codecmaps_kr TEST_ codecmaps_tw test_curses
    test_dbm test_gdb test_gdbm test_gl test_imgfile test_ioctl
    test_kqueue test_linuxaudiodev test_macos test_macostools
    test_ossaudiodev test_pep277 test_scriptpackages test_smtpnet
    test_socketserver test_sqlite test_startfile test_sunaudiodev
    test_timeout test_tk test_ttk_guionly test_uni code_FILE
    test_urllib2net test_urllibnet test_winreg test_winsound
    test_zipfile64
8跳过意想不到的linux2上:
    test_bsddb test_bsddb3 test_dbm test_gdb test_gdbm test_ioctl
    test_tk test_ttk_guionly
使:*** [测试]错误1

的Python 2.7

下面是Python 2.7版失败的测试:

  LD_LIBRARY_PATH = /选择/ standingcloud /堆栈/ pythonbrew /建设/ Python的2.7:./python -E -c'进口SYS;从进口sysconfig中get_platform;打印get_platform()+ - +内容sys.version [0:3]>平台
找到./Lib -name'*的.py [CO]'-print | xargs的RM -f
LD_LIBRARY_PATH = /选择/ standingcloud /堆栈/ pythonbrew /建设/ Python的2.7:./python -wd -3 -E -tt ./Lib/test/regrtest.py -l
== CPython的2.7(R27:82500,2011年6月16日,15时25分09秒)[GCC 4.2.4(Ubuntu的4.2.4-1ubuntu4)
==的Linux 2.6.18.8-linode22-i686的与 - Debian的莱尼-SID小尾数
== /opt/standingcloud/stack/pythonbrew/build/Python-2.7/build/test_python_13541.... SNIP ....test_distutils
在/ usr /斌/劳工处:找不到-lpython2.7
collect2:劳工处返回1退出状态
测试test_distutils失败 - 回溯(最近通话最后一个):
  文件/opt/standingcloud/stack/pythonbrew/build/Python-2.7/Lib/distutils/tests/test_build_ext.py,269线,在test_get_outputs
    cmd.run()
  文件/opt/standingcloud/stack/pythonbrew/build/Python-2.7/Lib/distutils/command/build_ext.py,340线,在运行
    self.build_extensions()
  文件/opt/standingcloud/stack/pythonbrew/build/Python-2.7/Lib/distutils/command/build_ext.py,449线,在build_extensions
    self.build_extension(EXT)
  文件/opt/standingcloud/stack/pythonbrew/build/Python-2.7/Lib/distutils/command/build_ext.py,531线,在build_extension
    TARGET_LANG =语)
  文件/opt/standingcloud/stack/pythonbrew/build/Python-2.7/Lib/distutils/ccompiler.py,741线,在link_shared_object
    extra_ preargs,extra_postargs,build_temp,TARGET_LANG)
  文件/opt/standingcloud/stack/pythonbrew/build/Python-2.7/Lib/distutils/unixccompiler.py,258线,在链接
    提高LinkError,味精
LinkError:命令'GCC'失败,退出状态1.... SNIP ....测试test_file里面失败 - 出现多个错误;在运行的详细信息详细模式
test_file2k
测试test_file2k失败 - 回溯(最近通话最后一个):
  文件/opt/standingcloud/stack/pythonbrew/build/Python-2.7/Lib/test/test_file2k.py,线路211,在testStdin
    self.assertRaises(IO错误,sys.stdin.seek,-1)
Asse田:IO错误不提高.... SNIP ....339测试确定。
3测试失败:
    test_distutils test_file里面test_file2k
1测试改变了执行环境:
    test_site
41跳过测试:
    test_aepack test_al test_applesingle test_bsddb test_bsddb185
    test_bsddb3 test_cd test_cl TEST_ codecmaps_cn TEST_ codecmaps_hk
    TEST_ codecmaps_jp TEST_ codecmaps_kr TEST_ codecmaps_tw test_curses
    test_dbm test_gdb test_gdbm test_gl test_imgfile test_ioctl
    test_kqueue test_linuxaudiodev test_macos test_macostools
    test_ossaudiodev test_pep277 test_scriptpackages test_smtpnet
    test_socketserver test_sqlite test_startfile test_sunaudiodev
    test_timeout test_tk test_ttk_guionly test_uni code_FILE
    test_urllib2net test_urllibnet test_winreg test_winsound
    test_zipfile64
8跳过意想不到的linux2上:
    test_bsddb test_bsddb3 test_dbm test_gdb test_gdbm test_ioctl
    test_tk test_ttk_guionly
令:[测试]错误1(忽略)


解决方案

我想我找到了一种方法,使这项工作,而无需设置 LD_LIBRARY_PATH

我发现有一个叫做环境变量 LD_RUN_PATH 这就像 LD_LIBRARY_PATH ,除了你设定而它的编译的程序,并记住只要运行路径(所以你不需要在运行时设置 LD_LIBRARY_PATH

所以,如果你设置 LD_RUN_PATH 适当,同时运行pythonbrew安装你的Py​​thon,它应该当你运行它,找到它自己的共享库。例如,下面的命令成功对我来说,包括安装的distutils和PIP,使模块的安装已经准备就绪,无须任何设置。

  LD_RUN_PATH = $ HOME / .pythonbrew /蟒蛇/ Python的2.7.3 / lib目录pythonbrew安装-j2 -C--enable-共享'--force -v 2.7.3

然后我可以做 pythonbrew使用2.7.3 来激活它,它就可以工作,没有在你的shell初始化或任何设置任何环境变量。

当然,你需要提前知道pythonbrew将安装你的Py​​thon这样您就可以设置 LD_RUN_PATH 正确。通常情况下,这将是 $ HOME / .pythonbrew /蟒蛇/ Python- $ VERSION / lib目录,但如果不工作,你总是可以通过实际安装一次发现(不包括 - 使共享),然后找到 LIB 目录

我相信,因为安装与后发生的错误 - 使共享,你安装了Python发现系统Python的共享库并使用,这会导致问题,如果有任何一种错配的方式将两条蟒蛇建成。无论使用LD_LIBRARY_PATH或LD_RUN_PATH解决方案迫使你的Python中使用自己的共享库。

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

This happens when I use the --enable-shared option

The build.log file errors are shown below:

Python 3.2

Here are the failed tests for Python 3.2:

LD_LIBRARY_PATH=/opt/standingcloud/stack/pythonbrew/build/Python-3.2: ./python -E -c 'import sys ; from sysconfig import get_platform ; print(get_platform()+"-"+sys.version[0:3])' >platform
find ./Lib -name '*.py[co]' -print | xargs rm -f
LD_LIBRARY_PATH=/opt/standingcloud/stack/pythonbrew/build/Python-3.2: ./python -Wd -E -bb  ./Lib/test/regrtest.py -l 
== CPython 3.2 (r32:88445, Jun 16 2011, 15:07:10) [GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu4)]
==   Linux-2.6.18.8-linode22-i686-with-debian-lenny-sid little-endian
==   /opt/standingcloud/stack/pythonbrew/build/Python-3.2/build/test_python_18839
Testing with flags: sys.flags(debug=0, division_warning=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=1, verbose=0, bytes_warning=2, quiet=0)

....SNIP....

[197/349] test_os
test test_os failed -- Traceback (most recent call last):
  File "/opt/standingcloud/stack/pythonbrew/build/Python-3.2/Lib/test/test_os.py", line 646, in test_exist_ok_existing_directory
    os.makedirs(path, mode=mode, exist_ok=True)
  File "/opt/standingcloud/stack/pythonbrew/build/Python-3.2/Lib/os.py", line 152, in makedirs
    mkdir(name, mode)
OSError: [Errno 17] File exists: '@test_18839_tmp/dir1'

....SNIP....

321 tests OK.
1 test failed:
    test_os
27 tests skipped:
    test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp
    test_codecmaps_kr test_codecmaps_tw test_curses test_dbm_gnu
    test_dbm_ndbm test_gdb test_ioctl test_kqueue test_ossaudiodev
    test_pep277 test_smtpnet test_socketserver test_sqlite
    test_startfile test_timeout test_tk test_ttk_guionly
    test_unicode_file test_urllib2net test_urllibnet test_winreg
    test_winsound test_xmlrpc_net test_zipfile64
5 skips unexpected on linux2:
    test_dbm_gnu test_dbm_ndbm test_ioctl test_tk test_ttk_guionly
sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='/dev/null' mode='a' encoding='ANSI_X3.4-1968'>
make: *** [test] Error 1

Python 2.7.1

Here are the failed tests for Python 2.7.1:

./python -Wd -3 -E -tt  ./Lib/test/regrtest.py -l 
== CPython 2.7.1 (r271:86832, Jun 16 2011, 17:59:28) [GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu4)]
==   Linux-2.6.18.8-linode22-i686-with-debian-lenny-sid little-endian
==   /opt/standingcloud/stack/pythonbrew/build/Python-2.7.1/build/test_python_19286

....SNIP....

test test_file2k failed -- Traceback (most recent call last):
  File "/opt/standingcloud/stack/pythonbrew/build/Python-2.7.1/Lib/test/test_file2k.py", line 219, in testStdin
    self.assertRaises(IOError, sys.stdin.seek, -1)
AssertionError: IOError not raised

....SNIP....

343 tests OK.
2 tests failed:
    test_file test_file2k
41 tests skipped:
    test_aepack test_al test_applesingle test_bsddb test_bsddb185
    test_bsddb3 test_cd test_cl test_codecmaps_cn test_codecmaps_hk
    test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_curses
    test_dbm test_gdb test_gdbm test_gl test_imgfile test_ioctl
    test_kqueue test_linuxaudiodev test_macos test_macostools
    test_ossaudiodev test_pep277 test_scriptpackages test_smtpnet
    test_socketserver test_sqlite test_startfile test_sunaudiodev
    test_timeout test_tk test_ttk_guionly test_unicode_file
    test_urllib2net test_urllibnet test_winreg test_winsound
    test_zipfile64
8 skips unexpected on linux2:
    test_bsddb test_bsddb3 test_dbm test_gdb test_gdbm test_ioctl
    test_tk test_ttk_guionly
make: *** [test] Error 1

Python 2.7

Here are the failed tests for Python 2.7:

LD_LIBRARY_PATH=/opt/standingcloud/stack/pythonbrew/build/Python-2.7: ./python -E -c 'import sys ; from sysconfig import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
find ./Lib -name '*.py[co]' -print | xargs rm -f
LD_LIBRARY_PATH=/opt/standingcloud/stack/pythonbrew/build/Python-2.7: ./python -Wd -3 -E -tt ./Lib/test/regrtest.py -l 
== CPython 2.7 (r27:82500, Jun 16 2011, 15:25:09) [GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu4)]
==   Linux-2.6.18.8-linode22-i686-with-debian-lenny-sid little-endian
==   /opt/standingcloud/stack/pythonbrew/build/Python-2.7/build/test_python_13541

....SNIP....

test_distutils
/usr/bin/ld: cannot find -lpython2.7
collect2: ld returned 1 exit status
test test_distutils failed -- Traceback (most recent call last):
  File "/opt/standingcloud/stack/pythonbrew/build/Python-2.7/Lib/distutils/tests/test_build_ext.py", line 269, in test_get_outputs
    cmd.run()
  File "/opt/standingcloud/stack/pythonbrew/build/Python-2.7/Lib/distutils/command/build_ext.py", line 340, in run
    self.build_extensions()
  File "/opt/standingcloud/stack/pythonbrew/build/Python-2.7/Lib/distutils/command/build_ext.py", line 449, in build_extensions
    self.build_extension(ext)
  File "/opt/standingcloud/stack/pythonbrew/build/Python-2.7/Lib/distutils/command/build_ext.py", line 531, in build_extension
    target_lang=language)
  File "/opt/standingcloud/stack/pythonbrew/build/Python-2.7/Lib/distutils/ccompiler.py", line 741, in link_shared_object
    extra_preargs, extra_postargs, build_temp, target_lang)
  File "/opt/standingcloud/stack/pythonbrew/build/Python-2.7/Lib/distutils/unixccompiler.py", line 258, in link
    raise LinkError, msg
LinkError: command 'gcc' failed with exit status 1

....SNIP....

test test_file failed -- multiple errors occurred; run in verbose mode for details
test_file2k
test test_file2k failed -- Traceback (most recent call last):
  File "/opt/standingcloud/stack/pythonbrew/build/Python-2.7/Lib/test/test_file2k.py", line 211, in testStdin
    self.assertRaises(IOError, sys.stdin.seek, -1)
AssertionError: IOError not raised

....SNIP....

339 tests OK.
3 tests failed:
    test_distutils test_file test_file2k
1 test altered the execution environment:
    test_site
41 tests skipped:
    test_aepack test_al test_applesingle test_bsddb test_bsddb185
    test_bsddb3 test_cd test_cl test_codecmaps_cn test_codecmaps_hk
    test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_curses
    test_dbm test_gdb test_gdbm test_gl test_imgfile test_ioctl
    test_kqueue test_linuxaudiodev test_macos test_macostools
    test_ossaudiodev test_pep277 test_scriptpackages test_smtpnet
    test_socketserver test_sqlite test_startfile test_sunaudiodev
    test_timeout test_tk test_ttk_guionly test_unicode_file
    test_urllib2net test_urllibnet test_winreg test_winsound
    test_zipfile64
8 skips unexpected on linux2:
    test_bsddb test_bsddb3 test_dbm test_gdb test_gdbm test_ioctl
    test_tk test_ttk_guionly
make: [test] Error 1 (ignored)

解决方案

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.

这篇关于编译问题的Python 3.2和2.7使用pythonbrew的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆