溫馨提示×

pip install的代理設置方法

小樊
619
2024-08-30 19:43:08
欄目: 編程語言

在無法直接訪問外部網絡的情況下,可以通過配置代理服務器來使用pip install命令。以下是幾種常見的代理設置方法:

臨時設置代理

  • Windows系統

    set HTTP_PROXY=http://[user:password@]proxy_server:port
    set HTTPS_PROXY=http://[user:password@]proxy_server:port
    
  • Linux/Unix系統

    export HTTP_PROXY=http://[user:password@]proxy_server:port
    export HTTPS_PROXY=http://[user:password@]proxy_server:port
    

永久設置代理

  • Windows系統

    %APPDATA%\pip\pip.ini文件中添加以下內容:

    [global]
    index-url=https://mirrors.aliyun.com/pypi/simple/
    proxy=http://[user:password@]proxy_server:port
    
    [install]
    trusted-host=mirrors.aliyun.com
    
  • Linux/Unix系統

    ~/.pip/pip.conf文件中添加以下內容:

    [global]
    index-url=https://mirrors.aliyun.com/pypi/simple/
    proxy=http://[user:password@]proxy_server:port
    
    [install]
    trusted-host=mirrors.aliyun.com
    

使用環境變量設置代理

  • Windows系統

    在命令行中輸入以下命令:

    set HTTP_PROXY=http://[user:password@]proxy_server:port
    set HTTPS_PROXY=http://[user:password@]proxy_server:port
    
  • Linux/Unix系統

    在命令行中輸入以下命令:

    export HTTP_PROXY=http://[user:password@]proxy_server:port
    export HTTPS_PROXY=http://[user:password@]proxy_server:port
    

使用Fiddler代理

  • 在Fiddler中設置代理賬號密碼,并將其加密后添加到Fiddler的OnBeforeRequest函數中。

使用第三方庫

  • 使用pproxy等第三方庫來搭建本地代理。

使用pip配置文件

  • pip.conf文件中設置代理,該文件的位置因操作系統而異。

希望這些方法能幫助您解決pip install時的代理設置問題。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女