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_sock开发者_开发知识库etserver 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.
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.
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.
精彩评论