Linux PYCURL 错误 6 - “无法解析主机 'mirrorlist.centos.org'”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20816133/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 01:43:05  来源:igfitidea点击:

PYCURL ERROR 6 - "Couldn't resolve host 'mirrorlist.centos.org'"

linuxnetworkingcentosvirtual-machinehyper-v

提问by pw94

I have a problem with CentOS 6.4 on Hyper-V. I can't install using yumor ping any DNS address. There is a announcement: Couldn't resolve host 'mirrorlist.centos.org'etc. I've been trying to fix it according to this video: http://www.youtube.com/watch?v=2BZHvVpXsg4but still nothing. What should I do? yum

我在 Hyper-V 上使用 CentOS 6.4 时遇到问题。我无法使用yum或 ping 任何 DNS 地址进行安装。有一个公告:Couldn't resolve host 'mirrorlist.centos.org'等等。我一直试图根据这个视频来修复它:http: //www.youtube.com/watch?v=2BZHvVpXsg4但仍然没有。我该怎么办? 百胜

ifconfig

如果配置

ping

平

回答by user3626608

Check network ... I use vm-player and add custom-virtual-network ( vmnet bridget )

检查网络...我使用 vm-player 并添加自定义虚拟网络( vmnet bridget )

Type:

类型:

ifdown eth0
ifup eth0
yum update

for me works ....

对我来说有效....

回答by imos

Try to add this line into the /etc/hosts

尝试将此行添加到 /etc/hosts

64.235.47.134    mirrorlist.centos.org

回答by diguage

I had the same problem.

我有同样的问题。

After logining my compony account, the networking can connect the Internet. But my vitrual manchine cound not login.

登录我的公司帐户后,网络可以连接Internet。但是我的虚拟机无法登录。

I change the network mode, use the "private network", then can connect the Internet.

我改变了网络模式,使用“私有网络”,然后就可以上网了。

Good luck.

祝你好运。

回答by deeenes

For the record: if you are in a Python shell, try to start a new one.I know the question is not about this, but it is the only top hit from google for this error. The original reason of the issue is still not clear as curlfrom command line downloaded the same URL with no problem, and I had no networking issue in any other application at the same time. I did ip link set <ifname> down/up, nmcli con down/up wiredwith no success. I added some of the domains to /etc/hosts, this once hasn't resolved the problem, but later at an other domain it worked. Here is a minimal example for easy testing:

作为记录:如果您在Python shell 中,请尝试开始一个新的。我知道问题与此无关,但它是 google 对此错误的唯一热门。问题的最初原因仍然不清楚,因为curl从命令行下载了相同的 URL 没有问题,同时我在任何其他应用程序中都没有网络问题。我做了ip link set <ifname> down/upnmcli con down/up wired没有成功。我将一些域添加到/etc/hosts,这一次还没有解决问题,但后来在另一个域中它起作用了。这是一个易于测试的最小示例:

import pycurl
import io

s = io.BytesIO()
c = pycurl.Curl()
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.setopt(pycurl.VERBOSE, 1)
c.setopt(pycurl.WRITEFUNCTION, s.write)
c.setopt(pycurl.URL, 'http://speedtest.ftp.otenet.gr/files/test100k.db')
c.perform()
s.seek(0)
print('Downloaded %u bytes.' % len(s.getvalue()))