Pythonbrew的解决方法失败,因为test_socket无法解决?

时间:2010-11-03 19:15:38

标签: python macos installer osx-snow-leopard

我正在使用pythonbrew在Snow Leopard上安装Python 2.6.6。它因readline错误而失败,然后是套接字错误。我从源代码安装了readline,这使安装程序在下次尝试时感到满意,但套接字错误仍然存​​在:

test_socket
test test_socket failed -- Traceback (most recent call last):
  File "/Users/gferguson/python/pythonbrew/build/Python-2.6.6/Lib/test/test_socket.py", line 483, in testSockName
    my_ip_addr = socket.gethostbyname(socket.gethostname())
gaierror: [Errno 8] nodename nor servname provided, or not known

使用Python系统展示:

>>> import socket
>>> my_ip_addr = socket.gethostbyname(socket.gethostname())
Traceback (most recent call last):
  File "", line 1, in 
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
>>> socket.gethostname()
'S1WSMA-JHAMI'
>>> socket.gethostbyname('S1WSMA-JHAMI')
Traceback (most recent call last):
  File "", line 1, in 
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
>>> socket.gethostbyname('google.com')
'74.125.227.20'

我用Ruby的IRB对问题进行了三角测量:

IPSocket.getaddress(Socket.gethostname)
SocketError: getaddrinfo: nodename nor servname provided, or not known

所以,我不确定这是解析器中的错误是不了解主机名,还是机器的配置中有些奇怪的东西,或者我们网络的DNS查找中有什么奇怪的东西,但无论安装程序是什么不高兴。

我认为这在安装程序中是一个良性的失败,所以我觉得安全强制测试成功,但我不知道如何告诉pythonbrew如何忽略该测试值或专门传递test_socket。

我也看到了以下状态,但尚未弄清楚它们是否有意义:

33 tests skipped:
    test_al test_bsddb test_bsddb3 test_cd test_cl test_codecmaps_cn
    test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr
    test_codecmaps_tw test_curses test_dl test_epoll test_gdbm test_gl
    test_imageop test_imgfile test_largefile test_linuxaudiodev
    test_normalization test_ossaudiodev test_pep277 test_py3kwarn
    test_smtpnet test_socketserver test_startfile test_sunaudiodev
    test_timeout test_urllib2net test_urllibnet test_winreg
    test_winsound test_zipfile64
1 skip unexpected on darwin:
    test_dl

任何人都有使用Snow Leopard上的pythonbrew安装Python 2.6.6的经验吗?


更新:我刚刚尝试使用Snow Leopard安装在MacBook Pro上的Python中的socket.gethostbyname(socket.gethostname())命令,并且它成功报告了我的IP,因此问题出现在系统配置中。我将在SO的兄弟“Apple”网站上询问是否有人知道它可能是什么。

2 个答案:

答案 0 :(得分:2)

我在OSX 10.7标准Perl和Macports Perl上遇到完全相同的问题。

似乎socket.gethostname()正在运行,但至少在我的Mac上运行回复,这与在终端中运行主机名相同,不起作用。

如果我这样做:

local_ip = socket.gethostbyname(local_ip+".local")

我的IP地址完全没问题。

所以这可能是OSX的怪癖,或者我的设置很奇怪。我会选择后者,因为Zeroconf.py在我的机器上因为这个问题而失败,我确信作者会抓住它。

答案 1 :(得分:0)

解决方案是--force pythonbrew尽管有错误但仍然可以安装。

我使用内置的Python,Perl和Ruby测试了套接字响应,他们在解析localhost名称时遇到了同样的问题。我在我的一个Linux机器上使用当前版本的Ruby和Python进行了测试,并且调用工作正常,所以我非常确定它不属于特定Mac的配置。

在强制安装后,我测试了套接字调用其他主机并获得了预期的结果,并且在执行其他网络任务时没有任何问题,所以我觉得一切都很好。