Pythonサードパーティライブラリをpipにインストールする際のMemoryErrorの解決策



Solution Memoryerror When Installing Python Third Party Libraries Pip



PipはMatplotライブラリをインストールし、次のメッセージのようなMemoryErrorエラーが発生します。

ファイル
「/usr/local/lib/python2.7/dist-packages/pip/_vendor/cachecontrol/filewrapper.py」、
54行目、読み取り中
self .__ callback(self .__ buf.getvalue())
ファイル「/usr/local/lib/python2.7/dist-packages/pip/_vendor/cachecontrol/controller.py」、
行205、cache_response内
self.serializer.dumps(request、response、body = body)、
ファイル「/usr/local/lib/python2.7/dist-packages/pip/_vendor/cachecontrol/serialize.py」、
81行目、ダンプ
).encode(“ utf8”)、MemoryError”ファイル“ /usr/local/lib/python2.7/dist-packages/pip/_vendor/cachecontrol/serialize.py”、
81行目、ダンプ
).encode(“ utf8”)、MemoryError”



pipキャッシュメカニズムは、インストールライブラリのファイル全体をメモリにキャッシュしようとします。キャッシュサイズが制限されている環境では、インストールパッケージが大きい場合にMemoryErrorエラーが発生します。
解決:

$ pip --help ... omit... --client-cert Path to SSL client certificate, a single file containing the private key and the certificate in PEM format. --cache-dir Store the cache data in . --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