我如何恢复 pip 升级

how do i revert an pip upgrade

我刚才做了以下命令,

pip install --upgrade ipykernel

不过,我得到了

Requirement already satisfied: ipykernel in ./anaconda3/lib/python3.8/site-packages (5.3.4)
Collecting ipykernel
  Downloading ipykernel-6.5.0-py3-none-any.whl (125 kB)
     |████████████████████████████████| 125 kB 4.3 MB/s 
Collecting ipython<8.0,>=7.23.1
  Downloading ipython-7.29.0-py3-none-any.whl (790 kB)
     |████████████████████████████████| 790 kB 9.2 MB/s 
Collecting debugpy<2.0,>=1.0.0
  Downloading debugpy-1.5.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.9 MB)
     |████████████████████████████████| 1.9 MB 126.8 MB/s 
Collecting matplotlib-inline<0.2.0,>=0.1.0
  Downloading matplotlib_inline-0.1.3-py3-none-any.whl (8.2 kB)
Collecting traitlets<6.0,>=5.1.0
  Downloading traitlets-5.1.1-py3-none-any.whl (102 kB)
     |████████████████████████████████| 102 kB 20.5 MB/s 
...
    Requirement already satisfied: python-dateutil>=2.1 in ./anaconda3/lib/python3.8/site-packages (from jupyter-client<8.0->ipykernel) (2.8.1)
    Requirement already satisfied: ptyprocess>=0.5 in ./anaconda3/lib/python3.8/site-packages (from pexpect>4.3->ipython<8.0,>=7.23.1->ipykernel) (0.7.0)
    Requirement already satisfied: wcwidth in ./anaconda3/lib/python3.8/site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython<8.0,>=7.23.1->ipykernel) (0.2.5)
    Requirement already satisfied: six>=1.5 in ./anaconda3/lib/python3.8/site-packages (from python-dateutil>=2.1->jupyter-client<8.0->ipykernel) (1.15.0)
    Installing collected packages: traitlets, matplotlib-inline, ipython, debugpy, ipykernel
      Attempting uninstall: traitlets
        Found existing installation: traitlets 5.0.5
        Uninstalling traitlets-5.0.5:
          Successfully uninstalled traitlets-5.0.5
      Attempting uninstall: ipython
        Found existing installation: ipython 7.22.0
        Uninstalling ipython-7.22.0:
          Successfully uninstalled ipython-7.22.0
      Attempting uninstall: ipykernel
        Found existing installation: ipykernel 5.3.4
        Uninstalling ipykernel-5.3.4:
          Successfully uninstalled ipykernel-5.3.4
    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.
    spyder 4.2.5 requires pyqt5<5.13, which is not installed.
    spyder 4.2.5 requires pyqtwebengine<5.13, which is not installed.
    conda-repo-cli 1.0.4 requires pathlib, which is not installed.
    Successfully installed debugpy-1.5.1 ipykernel-6.5.0 ipython-7.29.0 matplotlib-inline-0.1.3 traitlets-5.1.1

我想恢复我的命令,因为我的一些代码突然不起作用 .可能吗?谢谢!

好像安装了很多包。

更新 所以我实际上从我以前的conda env export > environment.yaml

中得到了我的environment.yaml

如果我这样做

conda env update --file environment.yaml --prune

它无法帮助我恢复到以前的版本....我可以强制我的基础环境完全恢复到 environment.yaml 吗?

我不相信 pip 会保留安装包的历史记录。如果您在升级时从终端输出了文本,pip 会输出将要安装的软件包列表、您拥有的版本以及要替换的版本。您可以通过

手动还原每个包

pip uninstall <package_name> && pip install <package_name>==<version_number>

编辑: 根据您的编辑,我建议您根据您的 conda 环境重新发布此问题。这是一个完全不同的系统,尽管它确实使用了 pip。

附带说明一下,您可能只需 运行

pip install traitlets==5.0.5
pip install ipykernel==5.3.4
pip install ipython==7.22.0