Windows下使用pip install各種奇奇怪怪的錯誤
阿新 • • 發佈:2019-01-27
UnicodeDecodeError
錯誤資訊:
<span style="font-family:Consolas, Courier New, Courier, mono, serif;"><span style="background-color: rgb(248, 248, 248);"></span></span><pre name="code" class="plain">UnicodeDecodeError: 'ascii' codec can't decode byte 0xcb in position 0: ordinal not in range(128)
報錯資訊已經說明是Unicode字元的問題。pip安裝python包時載入使用者目錄,Windows下的環境編碼為GBK,ascii無法編碼。
解決方案:
在python安裝目錄 Python27\Lib\site-packages 建一個檔案sitecustomize.py,內容為
import sys
sys.setdefaultencoding('gb2312')
只管執行“pip install package”,python會自動執行這個檔案。
ConnectionError
Exception information: Traceback (most recent call last): File "C:\Python34\lib\site-packages\pip\basecommand.py", line 122, in main status = self.run(options, args) File "C:\Python34\lib\site-packages\pip\commands\install.py", line 278, in run requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle) File "C:\Python27\lib\site-packages\pip\req.py", line 1177, in prepare_files url = finder.find_requirement(req_to_install, upgrade=self.upgrade) File "C:\Python34\lib\site-packages\pip\index.py", line 277, in find_requirement raise DistributionNotFound('No distributions at all found for %s' % req) pip.exceptions.DistributionNotFound: No distributions at all found for linkchecker
牆的問題($_$),
網上有挺多可用的源的,比如豆瓣:http://pypi.douban.com/simple/, 清華:https://pypi.tuna.tsinghua.edu.cn/simple
Windows下解決方案:
最簡單粗暴的辦法就是在C:\User\youname\pip目錄下新建檔案pip.ini,內容寫上
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
其他問題看提示資訊就能明白的就不寫了。所以好像跟標題有點不符額呵呵。。。