问题 bug
当运行 pip install $PAK_NAME
时,显示如下谬误:
ERROR: Exception:
Traceback (most recent call last):
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 188, in _main
status = self.run(options, args)
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 185, in wrapper
return func(self, options, args)
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 333, in run
reqs, check_supported_wheels=not options.target_dir
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 179, in resolve
discovered_reqs.extend(self._resolve_one(requirement_set, req))
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 362, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 313, in _get_abstract_dist_for
self._populate_link(req)
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 279, in _populate_link
req.link = self.finder.find_requirement(req, upgrade)
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_internal/index/package_finder.py", line 901, in find_requirement
req.name, specifier=req.specifier, hashes=hashes,
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_internal/index/package_finder.py", line 883, in find_best_candidate
candidates = self.find_all_candidates(project_name)
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_internal/index/package_finder.py", line 828, in find_all_candidates
project_url, link_evaluator=link_evaluator,
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_internal/index/package_finder.py", line 792, in process_project_url
html_page = self._link_collector.fetch_page(project_url)
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_internal/index/collector.py", line 612, in fetch_page
return _get_html_page(location, session=self.session)
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_internal/index/collector.py", line 451, in _get_html_page
resp = _get_html_response(url, session=session)
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_internal/index/collector.py", line 166, in _get_html_response
"Cache-Control": "max-age=0",
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_vendor/requests/sessions.py", line 543, in get
return self.request('GET', url, **kwargs)
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_internal/network/session.py", line 421, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_vendor/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_vendor/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_vendor/requests/adapters.py", line 449, in send
timeout=timeout
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_vendor/urllib3/connectionpool.py", line 672, in urlopen
chunked=chunked,
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_vendor/urllib3/connectionpool.py", line 387, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/http/client.py", line 1252, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/http/client.py", line 1298, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/http/client.py", line 1247, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/http/client.py", line 1026, in _send_output
self.send(msg)
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/http/client.py", line 966, in send
self.connect()
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_vendor/urllib3/connection.py", line 184, in connect
conn = self._new_conn()
File "/home/$USER_NAME/anaconda3/envs/py37/lib/python3.7/site-packages/pip/_vendor/urllib3/contrib/socks.py", line 90, in _new_conn
conn = socks.create_connection(AttributeError: module 'socks' has no attribute 'create_connection'
解决方案
狐疑是之前配置的全局代理的起因,查看~/.bashrc,在底部发现之前增加代码如下:
export TERM=xterm-256color
export all_proxy="socks5://127.0.0.1:51342"
故,采取以下操作:
- 正文掉 all_proxy,如
#export all_proxy="socks5://127.0.0.1:51342"
- 运行
unset all_proxy
胜利解决,前面某个工夫又呈现此问题,执行步骤 2 unset 全局代理即可!