使用 pip3 进行安装尝试导致“名称解析暂时失败”异常

使用 pip3 进行安装尝试导致“名称解析暂时失败”异常

我正在尝试从 Github 在 Ubuntu 16.04 上安装一个名为 QSpectrumAnalyzer 的 RF 工具。我的工作站通过公司代理服务器连接到互联网,我相信该服务器在 Ubuntu 中配置正确。Github 页面上安装 QSpectrumAnalyzer 的说明如下:

# Add SoapySDR PPA to your system
sudo add-apt-repository -y ppa:myriadrf/drivers

# Update list of packages
sudo apt-get update

# Install basic dependencies
sudo apt-get install python3-pip python3-pyqt5 python3-numpy python3-scipy soapysdr python3-soapysdr

# Install SoapySDR drivers for your hardware (e.g. RTL-SDR, Airspy, HackRF, LimeSDR, etc.)
sudo apt-get install soapysdr-module-rtlsdr soapysdr-module-airspy soapysdr-module-hackrf soapysdr-module-lms7

# Install QSpectrumAnalyzer locally for your current user
pip3 install --user qspectrumanalyzer

添加 Myriad-RF 存储库后,每个包都成功安装。但是,当我尝试运行 pip3 安装时,它会抛出三个异常。提前为这段时间太长道歉:

pip3 install --user qspectrumanalyzer
Collecting qspectrumanalyzer
Exception:
Traceback (most recent call last):
  File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-noneany.whl/urllib3/connection.py", line 137, in _new_conn
     (self.host, self.port), self.timeout, **extra_kw)
  File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/util/connection.py", line 67, in create_connection
     for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
  File "/usr/lib/python3.5/socket.py", line 732, in getaddrinfo
     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 560, in urlopen
     body=body, headers=headers)
  File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 346, in _make_request
     self._validate_conn(conn)
  File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 787, in _validate_conn
     conn.connect()
  File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connection.py", line 217, in connect
     conn = self._new_conn()
  File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connection.py", line 146, in _new_conn
     self, "Failed to establish a new connection: %s" % e)
requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fccf164ad30>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
   File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 209, in main
     status = self.run(options, args)
   File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 328, in run
     wb.build(autobuilding=True)
   File "/usr/lib/python3/dist-packages/pip/wheel.py", line 748, in build
     self.requirement_set.prepare_files(self.finder)
   File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 360, in prepare_files
     ignore_dependencies=self.ignore_dependencies))
   File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 512, in _prepare_file
     finder, self.upgrade, require_hashes)
   File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 273, in populate_link
     self.link = finder.find_requirement(self, upgrade)
   File "/usr/lib/python3/dist-packages/pip/index.py", line 442, in find_requirement
     all_candidates = self.find_all_candidates(req.name)
   File "/usr/lib/python3/dist-packages/pip/index.py", line 400, in find_all_candidates
     for page in self._get_pages(url_locations, project_name):
   File "/usr/lib/python3/dist-packages/pip/index.py", line 545, in _get_pages
     page = self._get_page(location)
   File "/usr/lib/python3/dist-packages/pip/index.py", line 648, in _get_page
     return HTMLPage.get_page(link, session=self.session)
   File "/usr/lib/python3/dist-packages/pip/index.py", line 757, in get_page
     "Cache-Control": "max-age=600",
   File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/sessions.py", line 480, in get
     return self.request('GET', url, **kwargs)
   File "/usr/lib/python3/dist-packages/pip/download.py", line 378, in request
     return super(PipSession, self).request(method, url, *args, **kwargs)
   File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/sessions.py", line 468, in request
     resp = self.send(prep, **send_kwargs)
   File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/sessions.py", line 576, in send
     r = adapter.send(request, **kwargs)
   File "/usr/share/python-wheels/CacheControl-0.11.5-py2.py3-none-any.whl/cachecontrol/adapter.py", line 46, in send
     resp = super(CacheControlAdapter, self).send(request, **kw)
   File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/adapters.py", line 376, in send
     timeout=timeout
   File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 610, in urlopen
     _stacktrace=sys.exc_info()[2])
   File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/util/retry.py", line 228, in increment
     total -= 1
TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'

我认为两个“名称解析暂时失败”错误是一个相当重要的线索,但我不知道名称解析在哪里出现故障。我使用 apt-get 从其他 Launchpad 存储库安装软件包时没有遇到任何问题,所以我不明白解析问题。顺便提一下,当我尝试使用 pip3 安装 Universal Radio Hacker 时,我也看到了几乎相同的异常。经过一番搜索,我添加了 8.8.8.8 和 8.8.4.4 作为其他 DNS 服务器,但结果没有改变。

令人恼火的是,几周前我为一位客户安装了这个完全相同的系统,没有出现任何问题。所以我确信这个安装是有效的。当然,我不再有权访问该系统,否则我只需克隆驱动器并完成它即可。

虽然我可以理解 Python 代码,但我并不是一名程序员,所以我在这方面的知识有限。虽然我使用 Red Hat 已有很长时间,但我对 Ubuntu 还是个菜鸟。

如果有人知道我应该去哪里找或者我可能遗漏了什么,我愿意倾听。提前谢谢。

答案1

我已经添加

nameserver 8.8.8.8

归档:

/etc/resolv.conf

它帮我解决了这个问题。

答案2

经过所有这些,最终发现是代理服务器上的 DNS 问题,而代理服务器并不由我管理。一旦问题解决,一切都会正常安装。

相关内容