[PYTHON] A story that stumbled when using pip in a proxy environment

I happened to have a chance to use Python at work, which I don't normally use at all. Since it is an environment under HTTP (s) proxy like a common company, I stumbled upon the introduction of the package with pip.

Target

Windows users using pip under HTTP (s) proxy

Event

I used pip to install the package in this way, but I ran into a package that I couldn't install. By the way, what is specified in the --cert parameter is a self-signed certificate for HTTPS communication via a proxy.

> set HTTP_PROXY=http://<id>:<password>@<fqdn>:<port>
> set HTTPS_PROXY=%HTTP_PROXY%
> pip install pywinpty --cert="C:\path\to\certs\cert.pem" -vvv
Collecting pywinpty
  Using cached pywinpty-0.5.7.tar.gz (49 kB)
    ERROR: Command errored out with exit status 1:
/* snip */
    WARNING: 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: self signed certificate in certificate chain (_ssl.c:1123)'))': /simple/cython/
/* snip */

It was clear that the cause was a poor connection with SSL/TLS. Therefore, I tried to specify the --trusted-host parameter in the command line argument, or prepare% APPDATA% \ pip \ pip.ini because I don't know what to call and how, but I couldn't find a solution.

Solutions

As introduced in pip: cert failed, but curl works, stackoverflow, setting the environment variable PIP_CERT solved the problem. It may also be solved using pip config set.

> set PIP_CERT=C:\path\to\certs\cert.pem
> pip config list
> pip install pywinpty

reference

Recommended Posts

A story that stumbled when using pip in a proxy environment
Pip install in proxy environment
A story that stumbled when I made a chatbot with Transformer
When pip fails under proxy environment
A story that Qiita really wanted to see under a proxy environment
The story that a hash error came out when using Pipenv
A story that stumbled upon installing matplotlib
A story that stumbled upon a comparison operation
A addictive story when using tensorflow on Android
A story when a directory is buggy with the django-admin start project command in a virtual environment using Pipenv
Use the latest pip in a virtualenv environment
Proxy settings when using pip or Jupyter Notebook
The story that fits in with pip installation
A complete guidebook to using pyenv, pip and python in an offline environment
What's in that variable (when running a Python script)
SoC FPGA: A small story when using on Linux
A swampy story when using firebase on AWS lamda
Set a proxy for Python pip (described in pip.ini)
A story that was convenient when I tried using the python ip address module
A story that an error occurred when PyInstaller was used in a program that uses googleapiclient
A story about PHP that was okay in the development environment but buggy in the production environment LEVEL 1-3 + 1
Collaborate in a remote environment
A memo when creating a directed graph using Graphviz in Python
A story about installing matplotlib using pip with an error
Resolve a Segmentation fault that occurs in Ubuntu 16.04+ Tensorflow environment
A story that went missing when I specified a path starting with a tilde (~) in python open
Install Jupiter Notebook on Windows with pip in proxy environment
A story that makes it easier to see Model debugging in the Django + SQLAlchemy environment
Scripts that can be used when using bottle in Python
Precautions that must be understood when building a PYTHON environment
Test discovery fails when using tensorflow in vscode + pytest environment
Problems when using Elasticsearch as a data source in Redash
When using property, use a class that inherits object (new-style class)
A story that didn't work when I tried to log in with the Python requests module
Proxy settings for python pip in a corporate environment don't work (for example, Python 3.7.5 is OK, but 3.7.6 is NG)
The story that the Homebrew environment was blown away when Anaconda was installed
A story that I fixed when I got Lambda logs from Cloudwatch Logs
A story about a build error in a shared library that references libusb
I get a can't set attribute when using @property in python
Tips for using Selenium and Headless Chrome in a CUI environment
Debug settings in virtual environment when using Pipenv with VS Code
What I stumbled upon when using CodeIgniter on a Linux server
A memorandum when using beautiful soup
Proxy measures when using WEB API
Pip install (Windows) under Proxy environment
Precautions when using pit in Python
Build a go environment using Docker
A story about using Python's reduce
When creating a matrix in a list
UnicodeDecodeError occurs in pip (Windows environment)
Proxy error when running "pip install"
When using regular expressions in Python
When writing a program in Python
Introducing a library that was not included in pip on Python / Windows
Check points when MIDI does not work in a program using SDL_mixer
Commands that were important when building the Laravel environment in the Apache environment (Note)
[Memorandum] A story about trying OpenCV tutorial (face recognition) in a Windows environment
I made a Discord bot in Python that translates when it reacts
Notify using Notification Center when the execution environment is macOS in Python
A story that heroku that can be done in 5 minutes actually took 3 days
A useful note when using Python for the first time in a while