
怎么引入不同的庫?
-
在線安裝庫
1)pip install 模塊名
2)國內源:
清華:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/
華中理工大學:http://pypi.hustunique.com/
山東理工大學:http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/
3)臨時使用:
可以在使用pip的時候加引數-i https://pypi.tuna.tsinghua.edu.cn/simple
例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider,這樣就會從清華這邊的鏡像去安裝pyspider庫,
4)永久修改
Linux下,修改 ~/.pip/pip.conf (沒有就創建一個檔案夾及檔案,檔案夾要加“.”,表示是隱藏檔案夾)內容如下:
[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install] trusted-host=mirrors.aliyun.com
windows下,直接在user目錄中創建一個pip目錄,再新建檔案pip.ini,(例如:C:\Users\WQP\pip\pip.ini)內容同上,
-
import & from...import
import 模塊:匯入一個模塊;注:相當于匯入的是一個檔案夾,是個相對路徑, from…import:匯入了一個模塊中的一個函式;注:相當于匯入的是一個檔案夾中的檔案,是個絕對路徑, 所以使用上的的區別是當參考檔案時是: import //模塊.函式 from…import // 直接使用函式名使用就可以了
原文:
讓python pip使用國內鏡像
https://www.cnblogs.com/wqpkita/p/7248525.html
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/540113.html
標籤:Python
