pip 使用代理方式

| 选择喜欢的代码风格  

pip --proxy


pip 要通过代理服务器安装 Python 包,请执行以下操作:

Linux
sudo pip install --proxy http://<usr_name>:<password>@<proxyserver_name>:<port#> <pkg_name> 
Windows
pip install --proxy http://<usr_name>:<password>@<proxyserver_name>:<port#> <pkg_name>

例如我在下载 Python 的 EasyOCR 的包、Pytorch,可以类似这样:

pip3 install torch torchvision torchaudio --proxy http://127.0.0.1:1080 --index-url https://download.pytorch.org/whl/cu117

...

pip install --proxy http://127.0.0.1:1080 easyocr

...

...

Collecting easyocr
  Downloading easyocr-1.7.0-py3-none-any.whl (2.9 MB)
     ---------------------------------------- 2.9/2.9 MB 4.3 MB/s eta 0:00:00
Requirement already satisfied: torch in e:\python310\lib\site-packages (from easyocr) (2.0.0)
Collecting torchvision>=0.5 (from easyocr)
  Downloading torchvision-0.15.2-cp310-cp310-win_amd64.whl (1.2 MB)
     ---------------------------------------- 1.2/1.2 MB 3.4 MB/s eta 0:00:00
Collecting opencv-python-headless (from easyocr)
  Downloading opencv_python_headless-4.7.0.72-cp37-abi3-win_amd64.whl (38.1 MB)
     ---------------------------------------- 38.1/38.1 MB 6.1 MB/s eta 0:00:00
Collecting scipy (from easyocr)
  Downloading scipy-1.10.1-cp310-cp310-win_amd64.whl (42.5 MB)
     ---------------------------------------- 42.5/42.5 MB 6.3 MB/s eta 0:00:00
Requirement already satisfied: numpy in e:\python310\lib\site-packages (from easyocr) (1.24.3)
Requirement already satisfied: Pillow in e:\python310\lib\site-packages (from easyocr) (9.5.0)
Collecting scikit-image (from easyocr)
  Downloading scikit_image-0.21.0-cp310-cp310-win_amd64.whl (22.8 MB)
     ---------------------------------------- 22.8/22.8 MB 6.5 MB/s eta 0:00:00
Collecting python-bidi (from easyocr)
  Downloading python_bidi-0.4.2-py2.py3-none-any.whl (30 kB)
Requirement already satisfied: PyYAML in e:\python310\lib\site-packages (from easyocr) (6.0)
Collecting Shapely (from easyocr)
  Downloading shapely-2.0.1-cp310-cp310-win_amd64.whl (1.4 MB)
     ---------------------------------------- 1.4/1.4 MB 7.2 MB/s eta 0:00:00
Collecting pyclipper (from easyocr)
  Downloading pyclipper-1.3.0.post4-cp310-cp310-win_amd64.whl (94 kB)
     ---------------------------------------- 94.5/94.5 kB 5.6 MB/s eta 0:00:00
Collecting ninja (from easyocr)
  Downloading ninja-1.11.1-py2.py3-none-win_amd64.whl (313 kB)
     ---------------------------------------- 313.0/313.0 kB 4.8 MB/s eta 0:00:00
Requirement already satisfied: requests in e:\python310\lib\site-packages (from torchvision>=0.5->easyocr) (2.28.2)
Collecting torch (from easyocr)
  Downloading torch-2.0.1-cp310-cp310-win_amd64.whl (172.3 MB)
     ---------------------------------------- 172.3/172.3 MB 4.3 MB/s eta 0:00:00
Requirement already satisfied: filelock in e:\python310\lib\site-packages (from torch->easyocr) (3.12.0)
Requirement already satisfied: typing-extensions in e:\python310\lib\site-packages (from torch->easyocr) (4.5.0)
Requirement already satisfied: sympy in e:\python310\lib\site-packages (from torch->easyocr) (1.11.1)

...

...

升级 Python 的 pip:

python -m pip install --upgrade pip --proxy http://127.0.0.1:1080 

python pip 扩展阅读:




发表评论