Python——pip常見錯誤彙總|待完善

第一種錯誤:Read time out

ERROR: Exception:
Traceback (most recent call last):
  File "c:\users\appdata\local\programs\python\python37\lib\site-packages\pip\_vendor\urllib3\response.py", line 397, in _error_catcher
    yield
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "c:\users\appdata\local\programs\python\python37\lib\site-packages\pip\_internal\cli\base_command.py", line 188, in main
    status = self.run(options, args)
  File "c:\users\appdata\local\programs\python\python37\lib\site-packages\pip\_vendor\urllib3\response.py", line 402, in _error_catcher
    raise ReadTimeoutError(self._pool, None, 'Read timed out.')
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

解決方案一:
windows輸入安裝命令行pip install --default-timeout=1000 pyspider(最後一個替換成自己要的庫)
linux輸入安裝命令行pip3 install -U --timeout 1000 pyspider
解決方案二:
在目錄C:\用戶\Administrator\下,新建pip文件夾,使用下面的內容創建pip.ini文件:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
#這邊的網址可以替換成下面任意一個,替換網址記得加/simple
#http://pypi.douban.com/
#http://pypi.hustunique.com/
#http://pypi.sdutlinux.org/
#http://pypi.mirrors.ustc.edu.cn/
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn

第二種錯誤

 ERROR: Command errored out with exit status 10:
     command: 'c:\users\appdata\local\programs\python\python37\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\AppData\\Local\\Temp\\pip-install-2knnzyvi\\pycurl\\setup.py'"'"'; __file__='"'"'C:\\Users\\AppData\\Local\\Temp\\pip-install-2knnzyvi\\pycurl\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: C:\Users\AppData\Local\Temp\pip-install-2knnzyvi\pycurl\
    Complete output (1 lines):
    Please specify --curl-dir=/path/to/built/libcurl
    ----------------------------------------
ERROR: Command errored out with exit status 10: python setup.py egg_info Check the logs for full command output.

這個錯誤也是在安裝pyspider時遇到的
解決方案一:(這個適用於很多情況,並不只是這個錯誤纔可以用)
第一步,安裝wheel
在這裏插入圖片描述
第二步,https://www.lfd.uci.edu/~gohlke/pythonlibs/ 去這裏下載pycurl文件(按自己所需下載,直接ctrl F找)
在這裏插入圖片描述
第三步,在命令窗口直接輸入pip install 下載的包的路徑和包名
在這裏插入圖片描述
第四步,輸入最開始的安裝命令(這裏就沒有錯誤了)
在這裏插入圖片描述
在這裏插入圖片描述

第三種錯誤 :Lock error

    TimeoutError: Lock error: Matplotlib failed to acquire the following lock file:
        C:\Users\鄭玉婷\.matplotlib\fontlist-v310.json.matplotlib-lock
    This maybe due to another process holding this lock file.  If you are sure no
    other Matplotlib process is running, remove this file and try again.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

大功告成!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章