1 2 3 4

pip 安装错误

今天在用pip安装pyspark时,遇到一个错误,折腾了半天,通过在网上查资料查了很久,最后得以解决。

pip安装Matplot库时遇到MemoryError的错误,类似以下的提示信息:

File
“/usr/local/lib/python2.7/dist-packages/pip/_vendor/cachecontrol/filewrapper.py”,
line 54, in read
self.__callback(self.__buf.getvalue())
File “/usr/local/lib/python2.7/dist-packages/pip/_vendor/cachecontrol/controller.py”,
line 205, in cache_response
self.serializer.dumps(request, response, body=body),
File “/usr/local/lib/python2.7/dist-packages/pip/_vendor/cachecontrol/serialize.py”,
line 81, in dumps
).encode(“utf8”), MemoryError” File “/usr/local/lib/python2.7/dist-packages/pip/_vendor/cachecontrol/serialize.py”,
line 81, in dumps
).encode(“utf8”), MemoryError”

查找到是由于pip的缓存机制尝试将希望安装库的整个文件缓存到内存,而在限制缓存大小的环境中如果安装包较大就会出现MemoryError的这个错误。
解决方法:

$ pip --help
......省略......
--client-cert <path>        Path to SSL client certificate, a single file
                            containing the private key and the certificate
                            in PEM format.
--cache-dir <dir>           Store the cache data in <dir>.
--no-cache-dir              Disable the cache.
--disable-pip-version-check
                            Don't periodically check PyPI to determine
                            whether a new version of pip is available for
                            download. Implied with --no-index.

可以看到pip有个–no-cache-dir参数,失能缓冲即可。

$pip --no-cache-dir install matplotlib

在弄完这个以后,我以为就会和网上的情况一样就好了,但是万万没想到,还是报错,于是我又找啊找啊

终于有找到一个解决方法,报错与之前的报错类似,解决方法如下:

wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
python get-pip.py
pip install --upgrade setuptools

在执行这三行命令后,问题得以解决,看来是自己的pip有问题,所以重新下载后就好了。

 

文章参考地址:pip安装Python第三方库时MemoryError的解决方法_Chan的博客-CSDN博客

pip 安装错误 Command "python setup.py egg_info" failed with error code - 靳闯博客 (jinchuang.org)

posted @ 2022-03-04 20:04  小陈的太阳  阅读(155)  评论(0编辑  收藏  举报