简体   繁体   中英

Anaconda "Inconsistent environment" and Spyder not recognising Imported Modules

I have been having a problem with my Spyder distribution since I attempted to install a new package (scikit-image): After attempting to install it, initially my Spyder IDE editor, even though the program itself seemed to respond, would not launch the IDE; Following some inte.net advice, I ran various commands, including 'conda update -all' and 'conda --reset' and eventually I got it to open up again.

However, it seems now that I have kind of broken my installation: Spyder IDE does not recognize any installed modules, and whenever I try to import a package for testing it either responds "AttributeError: module 'numpy' has no attribute ' version '" (ie via import pandas or matplotlib) or simply 'module not found' (ie import sklearn).

Every solution I have tried so far, like "conda update conda", "conda install conda / anaconda" have so far been met with the "Inconsistent Environment" error and nothing helps so far:

(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%|█▎        

And then it goes on and on with this, which I cancel as it takes forever to run and I do not understand what it does. What should I do? Should I have to delete and reinstall Anaconda? Would that mean I would also delete any custom packages (which there are plenty)?

I do have to note I am still in the dark about how the whole Anaconda package management, virtual environments, and paths work, so if anyone would also be kind enough to link any good sources explaining those things would be extra helpful.

Many thanks for any help!

The conda documentation should tell you what you need to get started.

The reason your problem occurred is that if you try to install or upgrade packages in your base environment, conda has to try and find mutually compatible versions of every single package in the Anaconda distribution, and that may be impossible or involve many package downgrades.

The simple answer is always to create a new environment, from the Navigator or using conda create , if you want a new or upgraded package. By specifying only the packages you need to use together, conda will be much more easily able to find a suitable combination.

If you want to use Spyder in the new environment, include the spyder package - or if you only use the command line, spyder-kernels which reduces the disk space needed.

This solved my problem.

I created a new environment using this:

"What worked for me:

run spyder from the environment (after source activate) go to Tools --> preferences --> python Interpreter and select the python file from the env you want to link to spyder ex: /home/you/anaconda3/envs/your_env/bin/python Worked on ubuntu 16, spyder3, python3.6." [LINK: https://stackoverflow.com/questions/30170468/how-to-run-spyder-in-virtual-environment/30170469#30170469]

Then proceed with installing the package I need. The issues were miraculously gone:)

Then I typed this in the anaconda environment

spyder activate MyEnvironment

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM