這是另一種方式。
搜索到的安裝庫的方式多數是:在桌面上win+R鍵運行終端,輸入命令,安裝不了,發現安裝不了。
1、打開pycharm;
2、軟件下部的Terminal終端(需要運行一個代碼才能出現,任何代碼都可);
3、有時候使用默認的官方網址下載安裝包網速較慢,或者出現connection timeou報錯。這時我們可以使用-i參數修改成從國內鏡像下載安裝。國內幾個pip源網址如下:
清華:https://pypi.tuna.tsinghua.edu.cn/simple
阿里:http://mirrors.aliyun.com/pypi/simple/
豆瓣:http://pypi.douban.com/simple/
華中理工大學:http://pypi.hustunique.com/
山東理工大學:http://pypi.sdutlinux.org/
中國科學技術大學:http://pypi.mirrors.ustc.edu.cn/
4、安裝命令:pip install 模塊名 -i 國內源
? ? ?其他安裝命令:pip3 install 模塊名(or + -i 國內源)
5、pip升級到7.0以后,在使用http鏡像進行包安裝及升級的時候往往會有如下提示:
Collecting beautifulsoup4
The repository located at xxx.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with ‘–trusted-host xxx.com’.
這時候根據提示在最后添加–trusted-host + 鏡像官網即可。
例如:
pip install 模塊名 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
?