Python - urllib2/wget/curl 无法连接,Mac OS X
原帖在最后。 我发现这不是Python特有的,而且curl/wget/telnet也不起作用。
我现在有一个部分解决方案:以 root 身份运行所有内容...... 即 sudo ipython 然后运行示例或 sudo wget python.org
嗨,
我对网络/python 完全陌生。我需要从我的笔记本电脑(Mac Os X 10.6.6)访问带有 urllib2 的网页。我这样做:
import urllib2
response = urllib2.urlopen('http://www.python.org/')
我得到的是: urlopen 错误 [Errno 60] 操作超时 (在家里) 或者 urlopen 错误 [Errno 51] 网络无法访问 (在上班)。
我认为这是防火墙的问题,不幸的是我不知道如何授予对 urllib2 的访问权限。我已在防火墙设置中允许 python/ipython/Python 启动器的传入连接,但没有帮助...
我的 python 是 v2.6.1,urllib2 v2.6。
非常感谢!
The original post is at the end.
I found out that this is not python specific but also curl/wget/telnet don't work.
I have now a partial solution: run everything as root....
i.e. sudo ipython and then run the example or sudo wget python.org
Hi,
I'm completely new to networks/python. I'd need to access a web page with urllib2 from my laptop (Mac Os X 10.6.6). I do this:
import urllib2
response = urllib2.urlopen('http://www.python.org/')
What I get is either:
urlopen error [Errno 60] Operation timed out
(at home)
or
urlopen error [Errno 51] Network is unreachable
(at work).
I assume this is a problem with a firewall, unfortunately I can't figure out how to grant access to urllib2. I've allowed incoming connections for python/ipython/Python launcher in the firewall settings, but to no help...
My python is v2.6.1, urllib2 v2.6.
Thank you very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这与 Python 无关,问题是由于网络上的路由或防火墙配置造成的。
This has nothing to do with Python, the problem is due to your routing or firewall configuration on your network.
找到了部分解决方案:
以 root 身份运行所有内容...
现在还可以,但如果有人知道如何解决这个问题,我仍然想听听。
Found a partial solution:
running everything as root...
For now, it's OK, but if somebody knows how to solve this is, I'd still like to hear it.