简体   繁体   中英

Install Python Packages on Red Hat Linux 8.2 using PIP not working

Working in a Corporate environment which has proxy server and thus i am setting proxy details as advised in various forum. Software version details below

  • OS - Red Hat 8.2
  • Python Version - 3.6.8
  • PIP Version - pip 9.0.3

Tried setting up environment variable

export http_proxy=http://servername:port
export https_proxy=https://servername:port

Tried using trustedhost setting. Executing below command inside python virtual environment

pip install --proxy=<http://servername:port \
    --trusted-host pypi.python.org --trusted-host pypi.org \
    --trusted-host files.pythonhosted.org  Flask

Above command gives below Error

Collecting Flask
  Could not find a version that satisfies the requirement Flask (from versions: )
No matching distribution found for Flask

If i remove trustedhost setting i get certification error

Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:897)'),)': /simple/flask/
Could not fetch URL https://pypi.python.org/simple/flask/: There was a problem confirming the ssl certificate:
    HTTPSConnectionPool(host='pypi.python.org', port=443): 
        Max retries exceeded with url: /simple/flask/ (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:897)'),)) - skipping

Kinda hard to reproduce, unfortunately, but at first glance, pypi repositories are going to be reached via HTTPS (I assume), not sure why you are explicitly specifying the schema for proxy:

pip install --proxy=<http://servername:port \
    --trusted-host pypi.python.org --trusted-host pypi.org \
    --trusted-host files.pythonhosted.org  Flask

Shouldn't it actually be:

pip install --proxy=https://servername:port \
    --trusted-host pypi.python.org --trusted-host pypi.org \
    --trusted-host files.pythonhosted.org  Flask

Alternatively, you could install the packages directly from sources (download them via wget - it's easier to set proxy there, I guess).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM