conda 卸载和安装时包不匹配

Packages don't match when conda uninstall and install

打开jupyter notebook时出现了ImportError所以我跟着here和运行conda uninstall pyzmq->conda install pyzmq.

我使用 conda 而不是 pip,因为人们说 “不要在 conda 环境下混淆 condapip 命令”。 =55=].

然后我开始意识到conda uninstall pyzmqconda install pyzmq的包是不同的:

  • conda uninstall pyzmq; 19 个软件包已删除
  • conda install pyzmq;仅安装 3 个软件包

为什么通过相同的 conda 命令安装和卸载的包不同?
他们不应该安装并重新安装完全对应的软件包吗?

我对 Anaconda 还是很陌生,如果您有任何更好的 conda envs 管理技巧以最大限度地减少 envs 损坏的风险,非常感谢您的建议.


conda uninstall

(my_env) C:\Users\koyamashinji>conda uninstall pyzmq
Collecting package metadata (repodata.json): done
Solving environment: done

## Package Plan ##
  environment location: C:\Users\koyamashinji\anaconda3\envs\my_env
  removed specs:
    - pyzmq

The following packages will be REMOVED:

  colorama-0.4.4-py_0
  decorator-4.4.2-py_0
  ipykernel-5.3.4-py36h5ca1d4c_0
  ipython-5.8.0-py36_1
  ipython_genutils-0.2.0-pyhd3eb1b0_1
  jupyter_client-6.1.7-py_0
  jupyter_core-4.7.0-py36haa95532_0
  libsodium-1.0.18-h62dcd97_0
  pickleshare-0.7.5-pyhd3eb1b0_1003
  prompt_toolkit-1.0.15-py_1
  pygments-2.7.2-pyhd3eb1b0_0
  python-dateutil-2.8.1-py_0
  pywin32-227-py36he774522_1
  pyzmq-20.0.0-py36hd77b12b_1
  simplegeneric-0.8.1-py36_2
  tornado-6.1-py36h2bbff1b_0
  traitlets-4.3.3-py36_0
  wcwidth-0.2.5-py_0
  zeromq-4.3.3-ha925a31_3

conda install

(my_env) C:\Users\koyamashinji>conda install pyzmq
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: C:\Users\koyamashinji\anaconda3\envs\my_env

  added / updated specs:
    - pyzmq


The following NEW packages will be INSTALLED:

  libsodium          pkgs/main/win-64::libsodium-1.0.18-h62dcd97_0
  pyzmq              pkgs/main/win-64::pyzmq-20.0.0-py36hd77b12b_1
  zeromq             pkgs/main/win-64::zeromq-4.3.3-ha925a31_3

Why do packages installed and uninstalled via same conda command differ? Shouldn't they install and reinstall exactly corresponding packages?

conda installconda uninstall应该安装和卸载完全对应的包,只要环境还没有坏.
我的环境已经坏了,可能是因为我之前使用 pip 安装了一些 jupyter 相关的包(你可以看到一些包是 py_0 这意味着它们是通过 [=19= 安装的) ].)


I am still pretty new to Anaconda, if you have any tricks for a better conda envs management to minimize the risk of broken envs, your advise is greatly appreciated.

我花了整整一周的时间试图弄清楚它们是如何工作的,这就是我得到的(目前)。

  • 确保在创建环境时指定 python Anaconda 支持的版本。
    选中 here 并在 conda create -n my_env python==version.

    时指定 python 版本
  • 确保在创建环境时也安装了所有已知的必需包
    conda create -n my_env python=version package_A, package_B ...
    正如 Official document 所说“在此环境中同时安装所有你想要的程序。一次安装 1 个程序会导致依赖冲突。

  • 确保您准确理解 conda install/uninstallpip install/uninstall 的作用。

conda install/uninstall

(my_env) C:\Users> conda install package_A  

# Installs : package_A + dependencies(dependency_1, dependency_2, dependency_3)
  

(my_env) C:\Users> conda uninstall package_A

# Uninstalls : package_A + dependencies(dependency_1, dependency_2, dependency_3)
(my_env) C:\Users> conda install package_A

# Installs : package_A + dependencies(dependency_1, dependency_2, dependency_3)    
  

(my_env) C:\Users> conda uninstall dependency_1

# Uninstalls : package_A + dependencies(dependency_1, dependency_2, dependency_3)

pip install/uninstall

(my_env) C:\Users> pip install package_A  

# Installs : package_A + dependencies(dependency_1, dependency_2, dependency_3)
  

(my_env) C:\Users> pip uninstall package_A

# Uninstalls : package_A ONLY
(my_env) C:\Users> pip install package_A

# Installs : package_A + dependencies(dependency_1, dependency_2, dependency_3)    
  

(my_env) C:\Users> pip uninstall dependency_1

# Uninstalls : dependency_1 ONLY