PyCharm

在Windows下开启MonoProxy,Pycharm的Terminal无法通过pip install 安装第三方库

  1. MonoProxy 已经开启了标准 或者 全局代理模式
  2. Pycharm 的Http Proxy 也已经配置了代理

image-20230810100330958

然后在Pycharm 的Terminal适用pip install 还是会报网络错误

> pip install shapely
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /simple/shapely/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /simple/shapely/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /simple/shapely/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /simple/shapely/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /simple/shapely/
ERROR: Could not find a version that satisfies the requirement shapely (from versions: none)
ERROR: No matching distribution found for shapely

推测不成功的原因可能是Windows配置的时候过滤了Terminal的代理,导致有问题

image-20230810101116343

是否可以通过这里的配置修改,让终端也能够走代理,这里以后再去尝试。

解决办法

  1. Pycharm的Http Proxy可以关掉

  2. 在终端安装的时候使用--proxy来代理,例如:

       pip install shapely --proxy=http://127.0.0.1:7078

    然后就可以愉快的安装了

    ```shell
    Collecting shapely
    Using cached shapely-2.0.1-cp37-cp37m-win_amd64.whl (1.4 MB)
    Collecting numpy>=1.14
    Downloading numpy-1.21.6-cp37-cp37m-win_amd64.whl (14.0 MB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 14.0/14.0 MB 7.4 MB/s eta 0:00:00
    Installing collected packages: numpy, shapely
    Successfully installed numpy-1.21.6 shapely-2.0.1

在PowerShell 和Anaconda 打开的终端中 安装第三方库也是一样的方法。