python安装第三方库时的一些bug

前序

飘得太久的,今天终于下定决心开始继续学习了,第一步:打开我的PyCharm,第二部:安装库 报错 o(╥﹏╥)o我太难了

  • D:\PyCharm_Project>pip install pdfminer3K
    WARNING: Retrying (Retry(total=4, connect=None, read=None
    eoutError("HTTPSConnectionPool(host='pypi.org', port=443)
    WARNING: Retrying (Retry(total=3, connect=None, read=None
    eoutError("HTTPSConnectionPool(host='pypi.org', port=443)
    Collecting pdfminer3K
    Downloading pdfminer3k-1.3.1.tar.gz (4.1 MB)
    |█▌ | 184 kB 4.2 kB/s
    ERROR: Exception:
    Traceback (most recent call last):
    File "d:\users\zxy\anaconda3\lib\site-packages\pip_ven
    dor\urllib3\response.py", line 425, in _error_catcher
    yield
    File "d:\users\zxy\anaconda3\lib\site-packages\pip_ven
    ...
    raise IncompleteRead(self._fp_bytes_read, self.length
    _remaining)
    File "d:\users\zxy\anaconda3\lib\contextlib.py", line 1
    30, in exit
    self.gen.throw(type, value, traceback)
    File "d:\users\zxy\anaconda3\lib\site-packages\pip_ven
    dor\urllib3\response.py", line 430, in _error_catcher
    raise ReadTimeoutError(self._pool, None, "Read timed
    out.")
    pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSCon
    nectionPool(host='files.pythonhosted.org', port=443): Rea
    d timed out.

尝试一:百度了一种做法即延时处理

  • D:\PyCharm_Project>pip --default-timeout=100 install pdfminer3k
    Collecting pdfminer3k
    Downloading pdfminer3k-1.3.1.tar.gz (4.1 MB)
    |██████ | 803 kB 11 kB/s eta
    ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREME
    update the hashes. Otherwise, examine the package contents caref
    pdfminer3k from https://files.pythonhosted.org/packages/8c/8
    ac2/pdfminer3k-1.3.1.tar.gz#sha256=1670de8ddb9aaff8f28d61abc918e
    Expected sha256 1670de8ddb9aaff8f28d61abc918e6a85c469fd8
    Got 08be56ca2bb19e6ebb7a9b3385c1b56861130b9f
    **

    尝试二:

  • D:\PyCharm_Project>pip --upgrade install pdfminer3k
    Collecting pdfminer3k
    Downloading pdfminer3k-1.3.1.tar.gz (4.1 MB)
    | | 10 kB 1.9 kB/s et
    ...
    raise ReadTimeoutError(self._pool, None, "Read timed out.")
    pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pytho

尝试三:完结篇

  • D:\PyCharm_Project>pip --default-timeout=200 install --upgrade pdfminer3k
    Collecting pdfminer3k
    Downloading pdfminer3k-1.3.1.tar.gz (4.1 MB)
    |████████████████████████████████| 4.1 MB 22 kB/s
    Requirement already satisfied, skipping upgrade: pytest>=2.0 in d:\users\zxy\anaconda3\lib\site-packages (from pdfminer3k) (3.8.0)
    Requirement already satisfied, skipping upgrade: ply>=3.4 in d:\users\zxy\anaconda3\lib\site-packages (from pdfminer3k) (3.11)
    Requirement already satisfied, skipping upgrade: py>=1.5.0 in d:\users\zxy\anaconda3\lib\site-packages (from pytest>=2.0->pdfminer3k) (1.6.0)
    Requirement already satisfied, skipping upgrade: six>=1.10.0 in d:\users\zxy\anaconda3\lib\site-packages (from pytest>=2.0->pdfminer3k) (1.11.0)
    ...
    168c5dbe243c6f
    Stored in directory: c:\users\zxy\appdata\local\pip\cache\wheels\a0\01\8f\91cc04fb57e65aac816dce1bf6d01d6769e103820967a31ba4
    Successfully built pdfminer3k
    Installing collected packages: pdfminer3k
    Successfully installed pdfminer3k-1.3.1

总结

pip下载超时处理 aise ReadTimeoutError(self._pool, None, ‘Read timed out.’)

方案一:对于比较小的库,可以延时处理

pip --default-timeout=100 install -U pip
pip --default-timeout=100 install 第三方库名

方案二:更换安装源

网上可以查找很多豆瓣源,如https://pypi.tuna.tsinghua.edu.cn/simple/ pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyecharts pip install -i https://pypi.tuna.tsinghua.edu.cn/simple 库名 出错使用这种 :pip install --index-url https://pypi.tuna.tsinghua.edu.cn/simple/ lightgbm `

方案三:下载离线包

python所有库:(https://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml),然后通过pip install 保存路径/加上下载的文件名 进行安装 ,如
pip install C:\Users\HP\Desktop\scikit_image-0.14.1-cp37-cp37m-win32.whl

参考博客链接:

猜你喜欢

转载自www.cnblogs.com/z-712/p/12359360.html