我需要专门安装psycopg2 v2.4.1.我不小心做了:
pip install psycopg2
Run Code Online (Sandbox Code Playgroud)
代替:
pip install psycopg2==2.4.1
Run Code Online (Sandbox Code Playgroud)
这安装2.4.4而不是早期版本.
现在即使在我pip卸载psycopg2并尝试使用正确的版本重新安装之后,看来pip正在重新使用它第一次下载的缓存.
如何强制pip清除其下载缓存并使用我在命令中包含的特定版本?
我在不同的virtualenv环境中安装了很多相同的软件包.有没有办法可以下载一次包然后从本地缓存中安装pip?
这会减少下载带宽和时间.
我尝试在 ubuntu 18.04 上安装 Pyautogui,但我不断收到以下错误消息:
$pip3 install pyautogui
Collecting pyautogui
Using cached https://files.pythonhosted.org/packages/45/70/c5d340fadb06106135b7fe9677fc6d275f3cd7f7e6f896316c4cfe6c022c/PyAutoGUI-0.9.37.tar.gz
Collecting pymsgbox (from pyautogui)
Using cached https://files.pythonhosted.org/packages/b6/65/86379ede1db26c40e7972d7a41c69cdf12cc6a0f143749aabf67ab8a41a1/PyMsgBox-1.0.6.zip
Collecting PyTweening>=1.0.1 (from pyautogui)
Using cached https://files.pythonhosted.org/packages/b9/f8/c32a58d6e4dff8aa5c27e907194d69f3b57e525c2e4af96f39c6e9c854d2/PyTweening-1.0.3.zip
Collecting Pillow (from pyautogui)
Using cached https://files.pythonhosted.org/packages/d1/24/f53ff6b61b3d728b90934bddb4f03f8ab584a7f49299bf3bde56e2952612/Pillow-5.2.0-cp36-cp36m-manylinux1_x86_64.whl
Collecting pyscreeze (from pyautogui)
Using cached https://files.pythonhosted.org/packages/c9/6e/e175fda37d76d7846a6cda8a4364dfd7c2d343139b0716c4f03194d14933/PyScreeze-0.1.17.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-6aakksn1/pyscreeze/setup.py", line 10, in <module>
with open("README.md", "r") as fh:
FileNotFoundError: [Errno 2] No such file or directory: 'README.md'
---------------------------------------- …Run Code Online (Sandbox Code Playgroud) 我尝试在 .gitlab-ci.yml 文件中使用缓存,但时间只会增加(通过添加空行进行测试)。我想缓存我用 pip 安装的 python 包。这是我安装和使用这些包的阶段(其他阶段使用 Docker):
image: python:3.8-slim-buster
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
paths:
- .cache/pip
stages:
- lint
- test
- build
- deploy
test-job:
stage: test
before_script:
- apt-get update
- apt-get install -y --no-install-recommends gcc
- apt install -y default-libmysqlclient-dev
- pip3 install -r requirements.txt
script:
- pytest tests/test.py
Run Code Online (Sandbox Code Playgroud)
运行此管道后,对于每个管道,管道时间都会增加。我按照 GitLab 文档中的这些步骤进行操作 - https://docs.gitlab.com/ee/ci/caching/#cache-python-dependency 虽然我没有使用 venv,因为它不需要它就可以工作。我仍然不确定为什么需要 PIP_CACHE_DIR 变量(如果不使用的话),但我遵循了文档。
缓存 python 依赖项的正确方法是什么?我不想使用 venv。
urllib3的pip安装挂在“由于etag进行缓存”上。我正在构建一个不允许您指定--no-cache-dir的AWS圣杯项目,因此我需要在没有该命令的情况下解决此问题。有任何想法吗?
在虚拟环境中使用Python 3.6.5和Pip 10.0.1。
(partnerdb-virtualenv) C:\Windows\SysWOW64\partnerdb-project>pip install urllib3 -vvv
Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect
Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect
Created temporary directory: C:\Users\Matt\AppData\Local\Temp\pip-ephem-wheel-cache-v0e8ikpl
Created temporary directory: C:\Users\Matt\AppData\Local\Temp\pip-req-tracker-d58lw_h5
Created requirements tracker 'C:\\Users\\Matt\\AppData\\Local\\Temp\\pip-req-tracker-d58lw_h5'
Created temporary directory: C:\Users\Matt\AppData\Local\Temp\pip-install-6qpv92ms
Collecting urllib3
1 location(s) to search for versions of urllib3:
* https://pypi.org/simple/urllib3/
Getting page https://pypi.org/simple/urllib3/
Looking up "https://pypi.org/simple/urllib3/" in the cache
Request header has "max_age" as 0, cache bypassed
Starting new HTTPS connection …Run Code Online (Sandbox Code Playgroud)