pip包冲突-两个包依赖同一包的不同版本
问题:rich 和metrics 依赖pygments的不同版本
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
metrics 0.3.3 requires Pygments==2.2.0, but you have pygments 2.17.2 which is incompatible.
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
rich 13.7.1 requires pygments<3.0.0,>=2.13.0, but you have pygments 2.2.0 which is incompatible.
情况一:两个包依赖的pygments版本有交集
解决思路:如果有交集,直接重新安装交集中的pygments版本
pip install pygments==xx.xx
情况二:两个包依赖的pygments版本没有交集
解决思路:如果没有交集,为了安全,将后安装的包版本降低或升高。一般来说后安装的包都是最新的包,可以适当降低版本以匹配依赖。
我这里是先安装了rich ,后安装metrics 出现了依赖包pygments的冲突。
- pip查看metrics可安装包版本
pip index versions metrics
> pip index versions metrics
WARNING: pip index is currently an experimental command. It may be removed/changed in a future release without prior warning.
metrics (0.3.3)
Available versions: 0.3.3, 0.3.2, 0.3.1, 0.3.0, 0.2.8, 0.2.7, 0.2.6, 0.2.5, 0.2.4, 0.2.3, 0.2.2, 0.2.1, 0.2.0
INSTALLED: 0.3.3
LATEST: 0.3.3
- 降低metrics包的版本
pip isntall metrics==0.2.5
考虑到是metrics后安装,而且版本是最新的版本,把metircs版本降低到0.2.5,这样就可以三个包共存。
具体选哪个版本是随缘选的。