pip apt proxy _vendor.requests.exceptions.SSLError: HTTPSConnectionPool(host=‘pypi.org‘, port=443

1,pip死活连不上,提示没有SSL模块

不指定proxy报这种: pip._vendor.requests.exceptions.SSLError: HTTPSConnectionPool(host=‘pypi.org’, port=443): Max retries exceeded with url: /pypi (Caused by SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”,))

指定了代理报这种:requests.exceptions.ProxyError: HTTPSConnectionPool(host=‘pypi.org’, port=443): Max retries exceeded with url: /pypi (Caused by ProxyError(‘Cannot connect to proxy.’, OSError(‘Tunnel connection failed: 407 Unauthorized’)))

不设代理:

$ pip3 search mxnet
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /pypi
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /pypi
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /pypi
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /pypi
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /pypi
Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/urllib3/connectionpool.py", line 588, in urlopen
    conn = self._get_conn(timeout=pool_timeout)
  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/urllib3/connectionpool.py", line 248, in _get_conn
    return conn or self._new_conn()
  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/urllib3/connectionpool.py", line 826, in _new_conn
    raise SSLError("Can't connect to HTTPS URL because the SSL "
pip._vendor.urllib3.exceptions.SSLError: Can't connect to HTTPS URL because the SSL module is not available.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/adapters.py", line 445, in send
    timeout=timeout
  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/urllib3/connectionpool.py", line 667, in urlopen
    **response_kw)
  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/urllib3/connectionpool.py", line 667, in urlopen
    **response_kw)
  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/urllib3/connectionpool.py", line 667, in urlopen
    **response_kw)
  [Previous line repeated 2 more times]
  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/urllib3/util/retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
pip._vendor.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /pypi (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 143, in main
    status = self.run(options, args)
  File "/usr/local/lib/python3.6/site-packages/pip/_internal/commands/search.py", line 48, in run
    pypi_hits = self.search(query, options)
  File "/usr/local/lib/python3.6/site-packages/pip/_internal/commands/search.py", line 65, in search
    hits = pypi.search({'name': query, 'summary': query}, 'or')
  File "/usr/local/lib/python3.6/xmlrpc/client.py", line 1112, in __call__
    return self.__send(self.__name, args)
  File "/usr/local/lib/python3.6/xmlrpc/client.py", line 1452, in __request
    verbose=self.__verbose
  File "/usr/local/lib/python3.6/site-packages/pip/_internal/download.py", line 788, in request
    headers=headers, stream=True)
  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/sessions.py", line 559, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pip/_internal/download.py", line 396, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/sessions.py", line 512, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/sessions.py", line 622, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/cachecontrol/adapter.py", line 53, in send
    resp = super(CacheControlAdapter, self).send(request, **kw)
  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/adapters.py", line 511, in send
    raise SSLError(e, request=request)
pip._vendor.requests.exceptions.SSLError: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /pypi (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",))

设了代理:

$ pip search https_proxy=https://10.xxx.xxx.xxx:8080 mxnet
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Unauthorized'))': /pypi
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Unauthorized'))': /pypi
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Unauthorized'))': /pypi
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Unauthorized'))': /pypi
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Unauthorized'))': /pypi
ERROR: Exception:
Traceback (most recent call last):
  File "/home/user1/env1/lib/python3.8/site-packages/urllib3/connectionpool.py", line 662, in urlopen
    self._prepare_proxy(conn)
  File "/home/user1/env1/lib/python3.8/site-packages/urllib3/connectionpool.py", line 950, in _prepare_proxy
    conn.connect()
  File "/home/user1/env1/lib/python3.8/site-packages/urllib3/connection.py", line 322, in connect
    self._tunnel()
  File "/usr/lib/python3.8/http/client.py", line 904, in _tunnel
    raise OSError("Tunnel connection failed: %d %s" % (code,
OSError: Tunnel connection failed: 407 Unauthorized

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user1/env1/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/home/user1/env1/lib/python3.8/site-packages/urllib3/connectionpool.py", line 747, in urlopen
    return self.urlopen(
  File "/home/user1/env1/lib/python3.8/site-packages/urllib3/connectionpool.py", line 747, in urlopen
    return self.urlopen(
  File "/home/user1/env1/lib/python3.8/site-packages/urllib3/connectionpool.py", line 747, in urlopen
    return self.urlopen(
  [Previous line repeated 2 more times]
  File "/home/user1/env1/lib/python3.8/site-packages/urllib3/connectionpool.py", line 719, in urlopen
    retries = retries.increment(
  File "/home/user1/env1/lib/python3.8/site-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /pypi (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Unauthorized')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user1/env1/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 186, in _main
    status = self.run(options, args)
  File "/home/user1/env1/lib/python3.8/site-packages/pip/_internal/commands/search.py", line 52, in run
    pypi_hits = self.search(query, options)
  File "/home/user1/env1/lib/python3.8/site-packages/pip/_internal/commands/search.py", line 71, in search
    hits = pypi.search({'name': query, 'summary': query}, 'or')
  File "/usr/lib/python3.8/xmlrpc/client.py", line 1109, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python3.8/xmlrpc/client.py", line 1450, in __request
    response = self.__transport.request(
  File "/home/user1/env1/lib/python3.8/site-packages/pip/_internal/network/xmlrpc.py", line 34, in request
    response = self._session.post(url, data=request_body,
  File "/home/user1/env1/lib/python3.8/site-packages/requests/sessions.py", line 581, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/home/user1/env1/lib/python3.8/site-packages/pip/_internal/network/session.py", line 405, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "/home/user1/env1/lib/python3.8/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/user1/env1/lib/python3.8/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/home/user1/env1/lib/python3.8/site-packages/cachecontrol/adapter.py", line 53, in send
    resp = super(CacheControlAdapter, self).send(request, **kw)
  File "/home/user1/env1/lib/python3.8/site-packages/requests/adapters.py", line 510, in send
    raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /pypi (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Unauthorized')))

2,安装ssl模块,报错

$ sudo apt install openssl libssl-dev --fix-missing
Reading package lists... Done
Building dependency tree
Reading state information... Done
openssl is already the newest version (1.1.1f-1ubuntu2).
Suggested packages:
  libssl-doc
The following NEW packages will be installed:
  libssl-dev
0 upgraded, 1 newly installed, 0 to remove and 6 not upgraded.
Need to get 1,582 kB of archives.
After this operation, 8,005 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://10.xxx.xxx.xxx:80/ac_portal/proxy.html?template=default&tabs=pwd&vlanid=0&url=http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal/main amd64 libssl-dev amd64 1.1.1f-1ubuntu2 [1,582 kB]
Err:1 http://10.xxx.xxx.xxx:80/ac_portal/proxy.html?template=default&tabs=pwd&vlanid=0&url=http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal/main amd64 libssl-dev amd64 1.1.1f-1ubuntu2
  File has unexpected size (2250 != 1581824). Mirror sync in progress? [IP: 10.xxx.xxx.xxx 8080]
  Hashes of expected file:
   - SHA256:d053feaaf2a2b55a23bb8e068b868ea0aa5c6a5ae41267228b25fc18a234cdba
   - SHA1:d20b1b280467409f6524088d788ef9ddb74c3e1f [weak]
   - MD5Sum:1cf36f95f856b7c37741f890b2d5d4b1 [weak]
   - Filesize:1581824 [weak]
E: Failed to fetch http://10.xxx.xxx.xxx:80/ac_portal/proxy.html?template=default&tabs=pwd&vlanid=0&url=http://mirrors.tuna.tsinghua.edu.cn/ubuntu/pool/main/o/openssl/libssl-dev_1.1.1f-1ubuntu2_amd64.deb  File has unexpected size (2250 != 1581824). Mirror sync in progress? [IP: 10.xxx.xxx.xxx 8080]
   Hashes of expected file:
    - SHA256:d053feaaf2a2b55a23bb8e068b868ea0aa5c6a5ae41267228b25fc18a234cdba
    - SHA1:d20b1b280467409f6524088d788ef9ddb74c3e1f [weak]
    - MD5Sum:1cf36f95f856b7c37741f890b2d5d4b1 [weak]
    - Filesize:1581824 [weak]
E: Internal Error, ordering was unable to handle the media swap

3,apt更新,还报错,明明上次用着好好的

$ sudo apt update
Err:4 https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64  InRelease
  Invalid response from proxy: HTTP/1.1 407 Unauthorized  Server: iis8.0  X-Frame-Options: ALLOWALL  Connection: keep-alive  Content-Type: text/html;  Content-Length: 0  Proxy-Authenticate: Basic realm="Sangfor Authorization"  Proxy-Connection: keep-alive  Set-Cookie: AUTHSESSID=db0d6fa8cb3b; HttpOnly;Secure;     [IP: 10.xxx.xxx.xxx 8080]
Err:5 https://nvidia.github.io/nvidia-container-runtime/stable/ubuntu18.04/amd64  InRelease
  Invalid response from proxy: HTTP/1.1 407 Unauthorized  Server: iis8.0  X-Frame-Options: ALLOWALL  Connection: keep-alive  Content-Type: text/html;  Content-Length: 0  Proxy-Authenticate: Basic realm="Sangfor Authorization"  Proxy-Connection: keep-alive  Set-Cookie: AUTHSESSID=403492c95784; HttpOnly;Secure;     [IP: 10.xxx.xxx.xxx 8080]
Err:10 https://nvidia.github.io/nvidia-docker/ubuntu18.04/amd64  InRelease
  Invalid response from proxy: HTTP/1.1 407 Unauthorized  Server: iis8.0  X-Frame-Options: ALLOWALL  Connection: keep-alive  Content-Type: text/html;  Content-Length: 0  Proxy-Authenticate: Basic realm="Sangfor Authorization"  Proxy-Connection: keep-alive  Set-Cookie: AUTHSESSID=d06bcc2ae2e7; HttpOnly;Secure;     [IP: 10.xxx.xxx.xxx 8080]
Get:1 http://10.xxx.xxx.xxx:80/ac_portal/proxy.html?template=default&tabs=pwd&vlanid=0&url=http://security.ubuntu.com/ubuntu xenial-security InRelease [2,250 B]
Err:1 http://10.xxx.xxx.xxx:80/ac_portal/proxy.html?template=default&tabs=pwd&vlanid=0&url=http://security.ubuntu.com/ubuntu xenial-security InRelease
  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
Get:2 http://10.xxx.xxx.xxx:80/ac_portal/proxy.html?template=default&tabs=pwd&vlanid=0&url=http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal InRelease [2,250 B]
Err:2 http://10.xxx.xxx.xxx:80/ac_portal/proxy.html?template=default&tabs=pwd&vlanid=0&url=http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal InRelease
  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
Get:3 http://10.xxx.xxx.xxx:80/ac_portal/proxy.html?template=default&tabs=pwd&vlanid=0&url=http://cn.archive.ubuntu.com/ubuntu xenial InRelease [2,250 B]
Err:3 http://10.xxx.xxx.xxx:80/ac_portal/proxy.html?template=default&tabs=pwd&vlanid=0&url=http://cn.archive.ubuntu.com/ubuntu xenial InRelease
  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
Get:6 http://10.xxx.xxx.xxx:80/ac_portal/proxy.html?template=default&tabs=pwd&vlanid=0&url=http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates InRelease [2,250 B]
Err:6 http://10.xxx.xxx.xxx:80/ac_portal/proxy.html?template=default&tabs=pwd&vlanid=0&url=http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates InRelease
  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
Get:7 http://10.xxx.xxx.xxx:80/ac_portal/proxy.html?template=default&tabs=pwd&vlanid=0&url=http://cn.archive.ubuntu.com/ubuntu xenial-updates InRelease [2,250 B]
Err:7 http://10.xxx.xxx.xxx:80/ac_portal/proxy.html?template=default&tabs=pwd&vlanid=0&url=http://cn.archive.ubuntu.com/ubuntu xenial-updates InRelease
  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
Get:8 http://10.xxx.xxx.xxx:80/ac_portal/proxy.html?template=default&tabs=pwd&vlanid=0&url=http://cn.archive.ubuntu.com/ubuntu xenial-backports InRelease [2,250 B]
Err:8 http://10.xxx.xxx.xxx:80/ac_portal/proxy.html?template=default&tabs=pwd&vlanid=0&url=http://cn.archive.ubuntu.com/ubuntu xenial-backports InRelease
  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
Get:9 http://10.xxx.xxx.xxx:80/ac_portal/proxy.html?template=default&tabs=pwd&vlanid=0&url=http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-backports InRelease [2,250 B]
Err:9 http://10.xxx.xxx.xxx:80/ac_portal/proxy.html?template=default&tabs=pwd&vlanid=0&url=http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-backports InRelease
  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
Get:11 http://10.xxx.xxx.xxx:80/ac_portal/proxy.html?template=default&tabs=pwd&vlanid=0&url=http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security InRelease [2,250 B]
Err:11 http://10.xxx.xxx.xxx:80/ac_portal/proxy.html?template=default&tabs=pwd&vlanid=0&url=http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security InRelease
  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
Reading package lists... Done
N: See apt-secure(8) manpage for repository creation and user configuration details.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
E: The repository 'http://security.ubuntu.com/ubuntu xenial-security InRelease' is no longer signed.
E: Failed to fetch http://security.ubuntu.com/ubuntu/dists/xenial-security/InRelease  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
N: See apt-secure(8) manpage for repository creation and user configuration details.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
E: The repository 'http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal InRelease' is no longer signed.
E: Failed to fetch http://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/focal/InRelease  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
N: See apt-secure(8) manpage for repository creation and user configuration details.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
E: The repository 'http://cn.archive.ubuntu.com/ubuntu xenial InRelease' is no longer signed.
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/xenial/InRelease  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
N: See apt-secure(8) manpage for repository creation and user configuration details.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
E: The repository 'http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates InRelease' is no longer signed.
E: Failed to fetch http://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/focal-updates/InRelease  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
N: See apt-secure(8) manpage for repository creation and user configuration details.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
E: The repository 'http://cn.archive.ubuntu.com/ubuntu xenial-updates InRelease' is no longer signed.
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
N: See apt-secure(8) manpage for repository creation and user configuration details.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
E: The repository 'http://cn.archive.ubuntu.com/ubuntu xenial-backports InRelease' is no longer signed.
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/xenial-backports/InRelease  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
E: Failed to fetch http://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/focal-backports/InRelease  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
E: The repository 'http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-backports InRelease' is no longer signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch http://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/focal-security/InRelease  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
E: The repository 'http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security InRelease' is no longer signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

解决:最后尼玛打开火狐才知道,原来是因为没有在web打开公司认证页面(大概率也就是登录10.xxx.xxx.xxx这个破网关)进行登录。

pip还是不行吗?
1,查好找不到的hostname的ip,如pypi.org,在/etc/hosts里面配置好pypi.org的ip
2,如果是在容器中使用pip,配置好docker的dns。参见URL
3,以上都做了还不行?运行这句:

# pip search --trusted-host=pypi.org --proxy=http://10.xxx.xxx.xxx:8080 mxnet
已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页