首页 > 解决方案 > Anaconda“环境不一致”和 Spyder 无法识别导入的模块

问题描述

自从我尝试安装新软件包(scikit-image)以来,我的 Spyder 发行版一直存在问题:尝试安装后,最初我的 Spyder IDE 编辑器,即使程序本身似乎响应,也不会启动 IDE ; 根据一些互联网建议,我运行了各种命令,包括“conda update -all”和“conda --reset”,最终我让它再次打开。

但是,现在看来我的安装有点坏了:Spyder IDE 无法识别任何已安装的模块,并且每当我尝试导入包进行测试时,它要么响应“AttributeError:模块'numpy'没有属性'版本'” (即通过导入 pandas 或 matplotlib)或简单地“找不到模块”(即导入 sklearn)。

到目前为止,我尝试过的每个解决方案,比如“conda update conda”、“conda install conda / anaconda”,都遇到了“Inconsistent Environment”错误,到目前为止没有任何帮助:

(base) C:\Users\black>conda update conda
Collecting package metadata (repodata.json): done
Solving environment: |
The environment is inconsistent, please check the package plan carefully
The following packages are causing the inconsistency:

  - defaults/win-64::anaconda==custom=py35h64770cb_0
  - bashtage/win-64::arch==4.4.1=np115py35_0
  - https://repo.continuum.io/pkgs/free/win-64::blaze==0.10.1=py35_0
  - defaults/win-64::bokeh==0.13.0=py35_0
  - defaults/win-64::bottleneck==1.2.1=py35h452e1ab_1
  - https://repo.continuum.io/pkgs/free/win-64::conda-build==1.21.3=py35_0
  - defaults/win-64::datashape==0.5.4=py35_1
  - conda-forge/win-64::deap==1.2.2=py35h830ac7b_0
  - https://repo.continuum.io/pkgs/free/win-64::dynd-python==0.7.2=py35_0
  - defaults/win-64::h5py==2.8.0=py35h3bdd7fb_2
  - conda-forge/noarch::hyperopt==0.1.2=py_0
  - defaults/win-64::imageio==2.4.1=py35_0
  - defaults/win-64::keras==2.2.2=0
  - defaults/win-64::keras-applications==1.0.4=py35_1
  - defaults/win-64::keras-base==2.2.2=py35_0
  - defaults/win-64::keras-preprocessing==1.0.2=py35_1
  - defaults/win-64::matplotlib==3.0.0=py35hd159220_0
  - defaults/win-64::mkl_fft==1.0.6=py35hdbbee80_0
  - defaults/win-64::mkl_random==1.0.1=py35h77b88f5_1
  - conda-forge/noarch::mlxtend==0.13.0=py_1
  - https://repo.continuum.io/pkgs/free/win-64::nbpresent==3.0.2=py35_0
  - https://repo.anaconda.com/pkgs/free/win-64::nb_anacondacloud==1.4.0=py35_0
  - defaults/win-64::pandas==0.23.4=py35h830ac7b_0
  - ankurankan/win-64::pgmpy==0.1.6=py35h8fcecb5_0
  - defaults/win-64::pygpu==0.7.6=py35h452e1ab_0
  - https://repo.anaconda.com/pkgs/free/win-64::pytables==3.2.2=np113py35_4
  - pytorch/win-64::pytorch-cpu==0.4.1=py35_cpuhe774522_1
  - defaults/win-64::quandl==3.4.2=py35_0
  - defaults/win-64::scipy==1.1.0=py35hc28095f_0
  - quantopian/win-64::ta-lib==0.4.9=np114py35_0
  - defaults/win-64::tensorboard==1.10.0=py35he025d50_0
  - conda-forge/win-64::tpot==0.9.5=py35_1
  - conda-forge/win-64::uncertainties==3.0.2=py35_1
failed
Solving environment: \
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
Examining numpy-base:   3%|█▉                                                       | 13/378 [00:00<00:00, 3681.70it/s]
Comparing specs that have this dependency:   0%|                                                | 0/30 [00:00<?, ?it/s]
| mparing specs that have this dependency:   3%|█▎        

然后它继续下去,我取消了它,因为它需要永远运行而且我不明白它的作用。我应该怎么办?我应该删除并重新安装 Anaconda 吗?这是否意味着我也会删除任何自定义包(有很多)?

我确实必须注意,我仍然对整个 Anaconda 包管理、虚拟环境和路径的工作方式一无所知,所以如果有人也愿意链接任何好的资源来解释这些事情将会非常有帮助。

非常感谢您的帮助!

标签: pythonanacondaconda

解决方案


conda文档应该告诉您需要什么才能开始。

出现问题的原因是,如果您尝试在base环境中安装或升级软件包,conda 必须尝试找到 Anaconda 发行版中每个软件包的相互兼容版本,这可能是不可能的或涉及许多软件包降级。

简单的答案总是创建一个新环境,从导航器或使用conda create,如果你想要一个新的或升级的包。通过仅指定您需要一起使用的包,conda将更容易找到合适的组合。

如果您想在新环境中使用 Spyder,请包含该spyder软件包 - 或者如果您只使用命令行,spyder-kernels这会减少所需的磁盘空间。


推荐阅读