Pip proxy error

Environment pip version: 20.2.3 Python version: 3.9 OS: Win10 64-bit Description When I'm trying to update pip using py -m pip install --upgrade pip a 'ProxySchemeUnknown' error occurs ...

Environment

  • pip version: 20.2.3
  • Python version: 3.9
  • OS: Win10 64-bit

Description
When I’m trying to update pip using py -m pip install --upgrade pip a ‘ProxySchemeUnknown’ error occurs with a plenty of other ‘File’ errors.

When I was looking for the solution to this problem, I found very similar issues, but they’re not the same:
#6555; psf/requests#5297

I think the problem is with my internet provider. I am sharing the internet with my laptop through a portable hotspot in my smartphone. Also, I changed TTL on the laptop.

Expected behavior
pip is updated.

How to Reproduce

  1. Open Windows’ CommandPrompt.
  2. Run py -m pip install --upgrade pip.
  3. An error occurs.

Output

C:UsersUser>py -m pip install --upgrade pip
Defaulting to user installation because normal site-packages is not writeable
ERROR: Exception:
Traceback (most recent call last):
  File "C:Program FilesPython39libsite-packagespip_internalclibase_command.py", line 228, in _main
    status = self.run(options, args)
  File "C:Program FilesPython39libsite-packagespip_internalclireq_command.py", line 182, in wrapper
    return func(self, options, args)
  File "C:Program FilesPython39libsite-packagespip_internalcommandsinstall.py", line 323, in run
    requirement_set = resolver.resolve(
  File "C:Program FilesPython39libsite-packagespip_internalresolutionlegacyresolver.py", line 183, in resolve
    discovered_reqs.extend(self._resolve_one(requirement_set, req))
  File "C:Program FilesPython39libsite-packagespip_internalresolutionlegacyresolver.py", line 388, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "C:Program FilesPython39libsite-packagespip_internalresolutionlegacyresolver.py", line 331, in _get_abstract_dist_for
    skip_reason = self._check_skip_installed(req)
  File "C:Program FilesPython39libsite-packagespip_internalresolutionlegacyresolver.py", line 254, in _check_skip_installed
    self.finder.find_requirement(req_to_install, upgrade=True)
  File "C:Program FilesPython39libsite-packagespip_internalindexpackage_finder.py", line 898, in find_requirement
    best_candidate_result = self.find_best_candidate(
  File "C:Program FilesPython39libsite-packagespip_internalindexpackage_finder.py", line 881, in find_best_candidate
    candidates = self.find_all_candidates(project_name)
  File "C:Program FilesPython39libsite-packagespip_internalindexpackage_finder.py", line 825, in find_all_candidates
    package_links = self.process_project_url(
  File "C:Program FilesPython39libsite-packagespip_internalindexpackage_finder.py", line 790, in process_project_url
    html_page = self._link_collector.fetch_page(project_url)
  File "C:Program FilesPython39libsite-packagespip_internalindexcollector.py", line 643, in fetch_page
    return _get_html_page(location, session=self.session)
  File "C:Program FilesPython39libsite-packagespip_internalindexcollector.py", line 455, in _get_html_page
    resp = _get_html_response(url, session=session)
  File "C:Program FilesPython39libsite-packagespip_internalindexcollector.py", line 152, in _get_html_response
    resp = session.get(
  File "C:Program FilesPython39libsite-packagespip_vendorrequestssessions.py", line 543, in get
    return self.request('GET', url, **kwargs)
  File "C:Program FilesPython39libsite-packagespip_internalnetworksession.py", line 421, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "C:Program FilesPython39libsite-packagespip_vendorrequestssessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "C:Program FilesPython39libsite-packagespip_vendorrequestssessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "C:Program FilesPython39libsite-packagespip_vendorcachecontroladapter.py", line 53, in send
    resp = super(CacheControlAdapter, self).send(request, **kw)
  File "C:Program FilesPython39libsite-packagespip_vendorrequestsadapters.py", line 412, in send
    conn = self.get_connection(request.url, proxies)
  File "C:Program FilesPython39libsite-packagespip_vendorrequestsadapters.py", line 309, in get_connection
    proxy_manager = self.proxy_manager_for(proxy)
  File "C:Program FilesPython39libsite-packagespip_vendorrequestsadapters.py", line 193, in proxy_manager_for
    manager = self.proxy_manager[proxy] = proxy_from_url(
  File "C:Program FilesPython39libsite-packagespip_vendorurllib3poolmanager.py", line 492, in proxy_from_url
    return ProxyManager(proxy_url=url, **kw)
  File "C:Program FilesPython39libsite-packagespip_vendorurllib3poolmanager.py", line 429, in __init__
    raise ProxySchemeUnknown(proxy.scheme)
pip._vendor.urllib3.exceptions.ProxySchemeUnknown: Not supported proxy scheme None
WARNING: You are using pip version 20.2.3; however, version 20.3.1 is available.
You should consider upgrading via the 'C:Program FilesPython39python.exe -m pip install --upgrade pip' command.

Здравствуйте.

На одной из машин с ОС Windows подключение к интернету возможно только через proxy.

Каким образом правильно выполнить настроку интерпретатора python (версия 3.5), чтобы появилась возможность накатывать пакеты, используя internet подключение через proxy?

p.s.
пробовал таким образом

cd "C:Program FilesPython35Scripts"
set HTTP_PROXY= user_proxy:pwd@proxy.new.ru:1111
pip install pysnmp

и еще вот так

“C:Program FilesPython35scriptspip.exe” –-proxy http://user_proxy:pwd@proxy.new.ru:1111 install requests

результат отрицательный…

Collecting requests
Exception:
Traceback (most recent call last):
  File "c:program filespython35libsite-packagespipbasecommand.py", line 21
5, in main
    status = self.run(options, args)
  File "c:program filespython35libsite-packagespipcommandsinstall.py", li
ne 299, in run
    requirement_set.prepare_files(finder)
  File "c:program filespython35libsite-packagespipreqreq_set.py", line 37
0, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "c:program filespython35libsite-packagespipreqreq_set.py", line 52
2, in _prepare_file
    finder, self.upgrade, require_hashes)
  File "c:program filespython35libsite-packagespipreqreq_install.py", lin
e 268, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "c:program filespython35libsite-packagespipindex.py", line 442, in
find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "c:program filespython35libsite-packagespipindex.py", line 400, in
find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "c:program filespython35libsite-packagespipindex.py", line 545, in
_get_pages
    page = self._get_page(location)
  File "c:program filespython35libsite-packagespipindex.py", line 648, in
_get_page
    return HTMLPage.get_page(link, session=self.session)
  File "c:program filespython35libsite-packagespipindex.py", line 757, in
get_page
    "Cache-Control": "max-age=600",
  File "c:program filespython35libsite-packagespip_vendorrequestssession
s.py", line 487, in get
    return self.request('GET', url, **kwargs)
  File "c:program filespython35libsite-packagespipdownload.py", line 378,
in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "c:program filespython35libsite-packagespip_vendorrequestssession
s.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "c:program filespython35libsite-packagespip_vendorrequestssession
s.py", line 585, in send
    r = adapter.send(request, **kwargs)
  File "c:program filespython35libsite-packagespip_vendorcachecontrolada
pter.py", line 46, in send
    resp = super(CacheControlAdapter, self).send(request, **kw)
  File "c:program filespython35libsite-packagespip_vendorrequestsadapter
s.py", line 370, in send
    conn = self.get_connection(request.url, proxies)
  File "c:program filespython35libsite-packagespip_vendorrequestsadapter
s.py", line 273, in get_connection
    proxy_manager = self.proxy_manager_for(proxy)
  File "c:program filespython35libsite-packagespip_vendorrequestsadapter
s.py", line 179, in proxy_manager_for
    **proxy_kwargs)
  File "c:program filespython35libsite-packagespip_vendorrequestspackage
surllib3poolmanager.py", line 284, in proxy_from_url
    return ProxyManager(proxy_url=url, **kw)
  File "c:program filespython35libsite-packagespip_vendorrequestspackage
surllib3poolmanager.py", line 229, in __init__
    proxy = parse_url(proxy_url)
  File "c:program filespython35libsite-packagespip_vendorrequestspackage
surllib3utilurl.py", line 189, in parse_url
    raise LocationParseError(url)
pip._vendor.requests.packages.urllib3.exceptions.LocationParseError: Failed to p
arse: user_proxy:pwd

When using pip behind a corporate environment, I got the following error.

Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)’))’: /simple/requests/

The error occurred because all internet access require to go through my corporate outbound HTTP proxy server.
In this tutorial, I will show you how you can configure pip to connect through the proxy server.

Get proxy settings

Before you set the proxy settings, you first need to know what they are. You either ask your system administrator or get the information from
Internet Explorer. It is much easier to get these information from Internet Explorer than from the system administrator. Here is how to get the
information from Internet Explorer.

  1. Open the Internet options of the Internet Explorer.
  2. Navigate to the Connections tab.
  3. At the bottom right, click on the LAN settings button.
  4. The value in the Address input field is the proxy settings that you need. What is before the colon(:) is the server address. What is after the colon(:) is the port number.
    IE - Proxy settings

Use —proxy command-line

With the proxy settings information, you can use the --proxy command-line option to specify a proxy in the form [user:passwd@]proxy.server:port.
For example, if you want to install requests package. You can do it using the following command line.

pip --proxy http://some-proxy-ip.com:8087 install requests

Use config file

Instead of typing out the --proxy option every time you run pip, you can set the proxy settings in the pip configuration file. The location
of this file vary slightly for different platforms.

  • For MS Windows, the configuration is located at %APPDATA%pippip.ini.
  • For MacOS, the configuration is located at $HOME/Library/Application Support/pip/pip.conf.
  • For Unix, the configuration is located at $HOME/.config/pip/pip.conf.

If path doesn’t exist, create it.

In your config file, set the followings.

[global]
proxy = http://some-proxy-ip.com:8087

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.

Environment

  • Red Hat Enterprise Linux (RHEL) 7.x
  • Red Hat Enterprise Linux (RHEL) 6.x
  • Red Hat Software Collections (RHSCL)

Issue

  • Facing connectivity issues while installing packages using pip
  • Receiving following errors while trying to install packages using pip
# pip install Beautifulsoup4
Collecting Beautifulsoup4
  Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', OSError(97, 'Address family not supported by protocol'))': /simple/beautifulsoup4/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', OSError(97, 'Address family not supported by protocol'))': /simple/beautifulsoup4/
  Could not find a version that satisfies the requirement Beautifulsoup4 (from versions: )
No matching distribution found for Beautifulsoup4.

Resolution

This error message will be received when there is a proxy configured and no proxy parameters have been set in your environment. As pip uses HTTP and any application that uses HTTP to transfer and fetch data will have to export the proxy parameters.

Export the proxy environment variable to install packages using pip:

# export http_proxy="http://PROXY_SERVER:PORT"      (for HTTP)

or

# export https_proxy="https://PROXY_SERVER:PORT"      (for HTTPS)   

If a proxy server uses authentication, set the proxy variables as follows:

# export http_proxy="http://USER:PASSWORD@PROXY_SERVER:PORT"      (for HTTP)

or

# export https_proxy="https://USER:PASSWORD@PROXY_SERVER:PORT"      (for HTTPS)

Now check if proxy has been set or not:

# env | grep proxy

Now, install the software using pip:

# scl enable rh-python35 bash
# pip install Beautifulsoup4


  • Product(s)

  • Red Hat Software Collections
  • Red Hat Enterprise Linux


  • Component

  • python


  • Category

  • Configure


  • Tags

  • python

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Понравилась статья? Поделить с друзьями:
  • Pip error command errored out with exit status 1
  • Pioneer ошибка sd05
  • Pioneer vsx 819h сброс ошибок
  • Pioneer vsx 527 сброс ошибок
  • Pioneer vsx 418 сброс ошибок