由于 test_socket 无法解析而导致 Pythonbrew 失败的解决方法?

发布于 2024-10-01 04:27:36 字数 2194 浏览 0 评论 0原文

我正在使用 pythonbrew 在 Snow Leopard 上安装 Python 2.6.6。它因读取行错误而失败,然后出现套接字错误。我从源代码安装了 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”网站上询问,看看是否有人知道它可能是什么。

I'm using pythonbrew to install Python 2.6.6 on Snow Leopard. It failed with a readline error, then a socket error. I installed readline from source, which made the installer happy on the next attempt, but the socket error remains:

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

Digging around with the system Python shows:

>>> 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'

I triangulated the problem with Ruby's IRB:

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

So, I'm not sure if this is a bug in the resolver not understanding the hostname, or if there's something weird in the machine's configuration, or if it's something weird in our network's DNS lookup, but whatever it is the installer isn't happy.

I think it's a benign failure in the installer though, so I feel safe to force the test to succeed, but I'm not sure how to tell pythonbrew how to ignore that test value or specifically pass test_socket.

I'm also seeing the following statuses but haven't figured out if they're significant yet:

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

Anyone have experience getting Python 2.6.6 installed with pythonbrew on Snow Leopard?


Update: I just tried the socket.gethostbyname(socket.gethostname()) command from Python installed on my MacBook Pro with Snow Leopard, and it successfully reported my IP back so it appears the problem is in the system config at work. I am going to ask at SO's sibling "Apple" site and see if anyone knows what it might be.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

只是在用心讲痛 2024-10-08 04:27:36

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

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

如果我这样做:

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

我得到我的 IP 地址完全没有问题。

所以这要么是 OSX 的怪癖,要么是我的设置相当奇怪。我会选择后者,因为 Zeroconf.py 由于这个问题在我的机器上失败了,我确信作者会发现这一点。

I'm having the exact same issue on OSX 10.7 standard Perl and Macports Perl.

It seems that socket.gethostname() is working, but on my Mac at least, running the reply to that, which is identical to running hostname in the terminal, does not work.

If I do:

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

I get my IP address no problem at all.

So it's either a OSX quirk, or my setup is rather strange. I'll go for the latter as Zeroconf.py fails on my machine because of this problem, something which I'm sure the author would have caught.

手心的温暖 2024-10-08 04:27:36

解决方案是尽管出现错误,还是--force pythonbrew 安装。

我使用内置的 Python、Perl 和 Ruby 测试了套接字响应,它们在解析本地主机名称时遇到了同样的问题。我在我的一台 Linux 机器上使用当前版本的 Ruby 和 Python 进行了测试,并且调用有效,因此我非常确定它超出了特定 Mac 配置的范围。

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

The solution was to --force pythonbrew to install in spite of the errors.

I tested the socket responses using the built-in Python, Perl and Ruby, and they had the same problem resolving the localhost name. I tested using a current version of Ruby and Python on one of my Linux boxes, and the calls worked, so I was pretty sure it was something outside of that particular Mac's configuration.

After forcing the install I tested the socket calls to other hosts and got the expected results and haven't had any problems doing other networking tasks so I think everything is fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文