ipython 使用 pip 安装 mermaid 和 ipykernel 时版本冲突

ipython version conflict while installing mermaid and ipykernel using pip

为了在 IPython 笔记本中使用美人鱼,我必须根据 this 安装 nb-mermaid。不幸的是,它卸载了以前版本的已安装 ipython 软件包,实际上有更新的版本。

Installing collected packages: IPython, nb-mermaid
  Attempting uninstall: IPython
    Found existing installation: ipython 8.2.0
    Uninstalling ipython-8.2.0:
      Successfully uninstalled ipython-8.2.0
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.
ipykernel 6.11.0 requires ipython>=7.23.1, but you have ipython 3.2.3 which is incompatible.
Successfully installed IPython-3.2.3 nb-mermaid-0.1.0

它将 ipython-8.2.0 降级为 ipython-3.2.3。实际上还有一个关于 this.

的悬而未决的问题

然后为了解决问题我尝试升级ipython包。

Installing collected packages: ipython
  Attempting uninstall: ipython
    Found existing installation: ipython 3.2.3
    Uninstalling ipython-3.2.3:
      Successfully uninstalled ipython-3.2.3
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.
nb-mermaid 0.1.0 requires IPython<4.0,>3.0, but you have ipython 8.2.0 which is incompatible.
Successfully installed ipython-8.2.0

另一个问题是 nb-mermaid 的依赖性。作为总结

Package Date Dependency Version
nb-mermaid-0.1.0 28 Jul 2015 ipython <4.0, >3.0
ipykernel-6.11.0 31 Mar 2022 ipython >=7.23.1

这表明没有任何重叠版本可用于安装 nb-mermaid-0.1.0ipykernel-6.11.0

是否有解决此问题的方法?

I have to install nb-mermaid according to this

难怪that project包含了一些很老的依赖:近6年没碰过,被作者抛弃了。就个人而言,我会完全避免使用它。

不幸的是,我在快速搜索中没有看到任何好的现代替代品。

如果你真的想使用它,我建议你使用 master 分支的最新提交,其中 the <4.0 constraint on IPython was removed:

pip install git+https://github.com/bollwyvl/nb-mermaid.git@103502e6