[PYTHON] Proxy settings when using pip or Jupyter Notebook

Introduction

Those who are having trouble with the following in an environment such as an in-house network via a Proxy server. ① I don't know how to set up via proxy with pip ② I don't know how to set up Jupyter Notebook via proxy ③ I don't know the URL setting value of the proxy. (← I personally fell in love with it)

Required information

Know the following information about the proxy. ・ Proxy user ・ Proxy password -Proxy server host -Proxy server port

① Setting method via proxy with pip

Launch the Anaconda prompt and do the following

#Proxy URL settings
set HTTPS_PROXY=http://{Proxy user}:{Proxy password}@{Proxy server host}:{Proxy server port}
#Installation library
set INSTALL_LIB_NAME=opencv-python

#pip command
pip install --user %INSTALL_LIB_NAME% --proxy %HTTPS_PROXY%

(2) Setting method via proxy in Jupyter Notebook

Launch the Anaconda prompt and do the following

ipython profile create

Because the ipython_config.py file is generated Execute the following command to edit. The file path differs depending on the environment, so the following values are for reference only.

notepad C:\\Users\\USER\\.ipython\\profile_default\\ipython_config.py

The edited part is optional, but to make the corrected part easy to understand, Added to the bottom.

import sys,os,os.path
os.environ['HTTP_PROXY']="http://{Proxy user}:{Proxy password}@{Proxy server host}:{Proxy server port}"
os.environ['HTTPS_PROXY']="http://{Proxy user}:{Proxy password}@{Proxy server host}:{Proxy server port}"

③ Proxy URL setting value

As soon as you know it. ..

http://{Proxy user}:{Proxy password}@{Proxy server host}:{Proxy server port}

reference

https://qiita.com/dyoshiha/items/96dea238afe7bf0acd1b

Recommended Posts

Proxy settings when using pip or Jupyter Notebook
Settings when using Jupyter Notebook under Proxy server
Using Graphviz with Jupyter Notebook
Use pip with Jupyter Notebook
Try using Jupyter Notebook dynamically
DEBUG settings when using Django
A story that stumbled when using pip in a proxy environment
Proxy measures when using WEB API
Snippet settings for python jupyter notebook
When pip fails under proxy environment
Somehow I tried using jupyter notebook
Proxy error when running "pip install"
Jupyter Notebook extension, nbextensions settings for myself
DB settings when using Django + SQLAlchemy + Alembic
Settings when reading S3 files with pandas from Jupyter Notebook on AWS
How to debug with Jupyter or iPython Notebook
Try using conda virtual environment with Jupyter Notebook
[Pythonocc] I tried using CAD on jupyter notebook
Try using Jupyter Notebook of Azure Machine Learning
Jupyter Notebook memo
Introducing Jupyter Notebook
Powerful Jupyter Notebook
Jupyter notebook password
Jupyter Notebook memo
Initial settings for using Python3.8 and pip on CentOS8
Initial settings when using the foursquare API in python
Open Jupyter Lab (or Jupyter Notebook) by specifying a directory