問題:No module named ‘sklearn’
解決辦法:
如果 pip install sklearn安裝失敗,換成國內的源就好了,比如:
pip install sklearn -i https://pypi.tuna.tsinghua.edu.cn/simple
安裝成功!
國內的源:
- 清華大學 https://pypi.tuna.tsinghua.edu.cn/simple/
- 阿里雲 http://mirrors.aliyun.com/pypi/simple/
- 中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/
- 豆瓣(douban) http://pypi.douban.com/simple/
- 中國科學技術大學 http://pypi.mirrors.ustc.edu.cn/simple/
其中清華的鏡像源5分鍾同步官網一次,建議使用。
用法:
-
pip install XXX -i http://pypi.douban.com/simple/ --trusted -host pypi.douban.com
即在原來pip install XXX命令后添加了 -i http://pypi.douban.com/simple/ --trusted -host pypi.douban.com 后面的鏈接是在國內的豆瓣鏡像,這樣就會臨時使用豆瓣的pypi鏡像去安裝庫了
如果所使用的鏡像源是未采用https加密協議的鏡像網站,則會產生"網站不受信任的問題",此時需要指定 –trusted-host參數手動授權信任。
-
pip install xxx -i https://pypi.tuna.tsinghua.edu.cn/simple
這樣就會臨時使用清華大學的pypi鏡像去安裝庫了。