AttributeError: module 'socks' has no attribute 'create_***

5838 단어 pip

문제 버그

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 전역 에이전트를 실행하면 됩니다!

    좋은 웹페이지 즐겨찾기