使用pip install 某些模塊發(fā)生安裝錯(cuò)誤:
Traceback (most recent call last):
File "d:\python3.7.4\lib\site-packages\pip_vendor\urllib3\response.py", line 425, in _error_catcher
yield
File "d:\python3.7.4\lib\site-packages\pip_vendor\urllib3\response.py", line 507, in read
data = self._fp.read(amt) if not fp_closed else b""
File "d:\python3.7.4\lib\site-packages\pip_vendor\cachecontrol\filewrapper.py", line 62, in read
data = self.__fp.read(amt)
File "d:\python3.7.4\lib\http\client.py", line 457, in read
n = self.readinto(b)
File "d:\python3.7.4\lib\http\client.py", line 501, in readinto
n = self.fp.readinto(b)
File "d:\python3.7.4\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
File "d:\python3.7.4\lib\ssl.py", line 1071, in recv_into
return self.read(nbytes, buffer)
File "d:\python3.7.4\lib\ssl.py", line 929, in read
return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out
During handling of the above exception, another exception occurred:
到網(wǎng)上搜了很多方法鸿市,包括使用管理員權(quán)限温艇,修改pip main方法耕捞,都不行梨睁,后來(lái)我想應(yīng)該就是簡(jiǎn)單的網(wǎng)速低導(dǎo)致斷鏈的問(wèn)題吧郭宝?pip可能不支持?jǐn)帱c(diǎn)續(xù)傳涡贱。
解決方法:
替換鏡像地址
python pip 安裝使用國(guó)內(nèi)鏡像源
<small style="font-size: 12px; letter-spacing: normal; color: rgb(171, 171, 171); display: block; text-align: right; font-family: Verdana, "Lucida Grande", Geneva, Arial, sans-serif; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">2019-07-04 10:55 微風(fēng)陽(yáng)光 閱讀(12968) 評(píng)論(1) 編輯 [收藏](javascript:void(0))</small>
國(guó)內(nèi)鏡像源
清華:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
中國(guó)科技大學(xué) https://pypi.mirrors.ustc.edu.cn/simple/
華中理工大學(xué):http://pypi.hustunique.com/
山東理工大學(xué):http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/
臨時(shí)使用
在使用pip的時(shí)候加參數(shù)-i https://pypi.tuna.tsinghua.edu.cn/simple
例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider钓葫,這樣就會(huì)從清華這邊的鏡像去安裝pyspider庫(kù)巧勤。
一勞永逸
Linux下嵌灰,修改 ~/.pip/pip.conf (沒(méi)有就創(chuàng)建一個(gè)文件夾及文件。文件夾要加“.”颅悉,表示是隱藏文件夾)
內(nèi)容如下:
|
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
|
windows下沽瞭,直接在user目錄中創(chuàng)建一個(gè)pip目錄,如:C:\Users\xx\pip剩瓶,新建文件pip.ini驹溃。內(nèi)容同上。
本機(jī)win10操作系統(tǒng)延曙,目錄:C:\Users\DELL\AppData\Roaming\pip\pip.ini
遇到的問(wèn)題
實(shí)際使用的時(shí)候豌鹤,一開(kāi)始使用清華的鏡像,在安裝時(shí)枝缔,總是提示
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
換了阿里的鏡像之后布疙,問(wèn)題得到了解決。