Unable to install packages using pip through proxy

Solution Verified - Updated -

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

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.

Comments