移除pip的缓存?

2024-04-26 17:57:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要特别安装psycopg2 v2.4.1。我不小心做到了:

 pip install psycopg2

而不是:

 pip install psycopg2==2.4.1

安装2.4.4而不是早期版本。

现在,即使在我卸载psycopg2并尝试用正确的版本重新安装之后,pip似乎正在重新使用它第一次下载的缓存。

如何强制pip清除其下载缓存并使用命令中包含的特定版本?


Tags: installpip命令版本psycopg2小心
3条回答

清除适合您系统的缓存目录

Linux和Unix

~/.cache/pip  # and it respects the XDG_CACHE_HOME directory.

苹果操作系统

~/Library/Caches/pip

窗口

%LocalAppData%\pip\Cache

来自https://pip.pypa.io/en/latest/reference/pip_install.html#caching的文档:

Starting with v6.0, pip provides an on-by-default cache which functions similarly to that of a web browser. While the cache is on by default and is designed do the right thing by default you can disable the cache and always access PyPI by utilizing the --no-cache-dir option.

如果使用pip 6.0或更新版本,请尝试添加^{} option

如果使用的pip早于pip 6.0,请使用pip install -U pip对其进行升级。

相关问题 更多 >