我在办公室的 VMware Player 上运行 ubuntu 14.10。
每当我尝试添加存储库时,都会出现此异常。
root@ubuntu:~# sudo add-apt-repository ppa:rvm/smplayer
Traceback (most recent call last):
File "/usr/lib/python3.4/urllib/request.py", line 1174, in do_open
h.request(req.get_method(), req.selector, req.data, headers)
File "/usr/lib/python3.4/http/client.py", line 1090, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python3.4/http/client.py", line 1128, in _send_request
self.endheaders(body)
File "/usr/lib/python3.4/http/client.py", line 1086, in endheaders
self._send_output(message_body)
File "/usr/lib/python3.4/http/client.py", line 924, in _send_output
self.send(msg)
File "/usr/lib/python3.4/http/client.py", line 859, in send
self.connect()
File "/usr/lib/python3.4/http/client.py", line 1221, in connect
super().connect()
File "/usr/lib/python3.4/http/client.py", line 836, in connect
self.timeout, self.source_address)
File "/usr/lib/python3.4/socket.py", line 509, in create_connection
raise err
File "/usr/lib/python3.4/socket.py", line 500, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
我选择 smplayer 只是为了测试 app-get。我能够设置浏览器,以便能够连接到互联网并 ping yahoo.com 之类的网站,但我不知道是否还有其他我遗漏的网络设置。
答案1
您必须定义代理环境变量并告诉 sudo 使用它(使用 -E 标志):
export http_proxy=http://<proxy>:<port>
export https_proxy=http://<proxy>:<port>
sudo -E add-apt-repository ppa:team-xbmc/ppa
如果必须使用代理的用户名和密码,请使用以下语法:
export https_proxy=<username>:<password>@<proxy>:<port>