UFO ET IT

다운로드 한 PIP 패키지를 캐시하는 방법

ufoet 2020. 12. 2. 22:17
반응형

다운로드 한 PIP 패키지를 캐시하는 방법


이 질문에 이미 답변이 있습니다.

PIP가 이전에 다운로드 한 패키지를 다시 다운로드하는 것을 어떻게 방지합니까? 여러 배포 판별 패키지에 의존하는 11MB 패키지 인 matplotlib의 설치를 테스트하고 있습니다. 를 실행할 pip install matplotlib마다 matplotlib를 다시 다운로드합니다. 어떻게 멈출 수 있습니까?


특정 환경 변수 PIP_DOWNLOAD_CACHE 를 사용하여 패키지가 저장 될 디렉토리를 가리킬 수 있습니다. 다시 설치하려면이 디렉토리에서 가져옵니다.

pip --download-cache비슷한 작업을해야하는 PIP에 대한 추가 옵션도있는 것 같지만 직접 시도한 적이 없습니다. 예를 들어 matplotlib매번 다시 다운로드 하지 않으려면 다음을 수행하십시오.

pip install --download-cache /path/to/pip/cache matplotlib

질문에 대한 답이 되었습니까?


새로운 Pip 버전 :

기본적으로 최신 Pip 버전은 이제 다운로드를 캐시합니다. 이 문서를 참조하십시오.

https://pip.pypa.io/en/stable/reference/pip_install/#caching

이전 Pip 버전의 경우 :

라는 구성 파일 ~/.pip/pip.conf을 만들고 다음 내용을 추가합니다.

[global]
download_cache = ~/.cache/pip

하나의 명령으로 :

printf '[global]\ndownload_cache = ~/.cache/pip\n' >> ~/.pip/pip.conf

당신은 할 수 있습니다

# download and extract package to build path
pip install --no-install matplotlib

# the build path could be found by 
pip install --help|grep Unpack\ packages\ into -A 2

# then rm pip-delete-this-directory.txt inside the build path
# this prevent pip from removing package from the build directory after install
# you could check the content of the file
rm build/pip-delete-this-directory.txt

# from now on you could install matplotlib quickly
# this uses single build directory 
# and can speed up compiling by caching intermediate objects.
pip install --no-download matplotlib

또한 패키지를 수동으로 다운로드 할 수 있습니다.

pip install -d dir_for_packages matplotlib

그런 다음 un-tar 및 python setup install나중에 설치하십시오 .

pip install --download-cache유사한 방식으로 작동 승 / 추가 검사 : 검색이 지정한 디렉토리에 패키지를 결과를 가지고 있으며,이 캐시되는 경우는 첫째, 웹에서 대상 패키지의 최신 또는 지정된 버전을 검색 download-cache, 캐시 된 패키지가 대신 사용됩니다 다운로드 예를 들면

pip install --download-cache . pymongo

pymongo 패키지를 현재 디렉토리에 다운로드합니다.

http%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fp%2Fpymongo%2Fpymongo-2.1.1.tar.gz
http%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fp%2Fpymongo%2Fpymongo-2.1.1.tar.gz.content-type

참고 URL : https://stackoverflow.com/questions/10336308/how-to-cache-downloaded-pip-packages

반응형