1

After installing the latest scikit-learn version (19) using conda in Anaconda Jupyter, all packages are showing ModuleNotFoundError - scikit learn, numpy, matplotlib, etc. This is happening for all conda packages. After uninstalling and reinstallling, I have the same problem.

My kernel specs :

sana@skb-linux:~$ . activate my_env
(my_env) sana@skb-linux:~$ jupyter kernelspec list
Available kernels:
  python3    /home/sana/anaconda3/envs/my_env/share/jupyter/kernels/python3

My code:

# scipy
import scipy
print('scipy: %s' % scipy.__version__)

Result:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-73263c49dde4> in <module>()
      1 # scipy
----> 2 import scipy
      3 print('scipy: %s' % scipy.__version__)

ModuleNotFoundError: No module named 'scipy'

enter image description here

Stephen
  • 8,508
  • 12
  • 56
  • 96
SKB
  • 771
  • 7
  • 14
  • 1
    Did you install those and open Jupyter notebook in the same environment or working in a different environment? – Space Impact Aug 30 '18 at 12:05
  • How did you install those packages? Using pip or conda? – Vivek Kumar Aug 30 '18 at 13:38
  • in same enviroement my_env bcz i have only one environment that i created while installing anaconda – SKB Aug 30 '18 at 15:03
  • i have installed all the pakages using conda only @vivek – SKB Aug 30 '18 at 15:04
  • i created my environment conda create --name my_env python=3 – SKB Aug 30 '18 at 16:20
  • problem solved but warning issues with import sklearn warning /home/sana/anaconda3/envs/my_env/lib/python3.7/site-packages/sklearn/utils/__init__.py:4: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working from collections import Sequence kindly solve this – SKB Aug 30 '18 at 18:49

3 Answers3

1

You can check for the install packages by typing !conda list in the notebook and check for scikit-learn package is there or not. If it's not present then you can install it by !pip install scikit-learn or !conda install -c anaconda scikit-learn

later try import sklearn it should work!.

There is a useful source here, including how to update or upgrade packages..

Chandu
  • 2,053
  • 3
  • 25
  • 39
  • yes all packages are install are shown in terminal conda list # packages in environment at /home/sana/anaconda3 scikit-learn 0.19.1 same for numpy matplotlib scipy – SKB Aug 30 '18 at 16:15
  • in every package i am importing casing same module problem – SKB Aug 30 '18 at 16:21
  • I have done fresh installation again showing same problem – SKB Aug 30 '18 at 16:41
  • which OS are you using? – Chandu Aug 30 '18 at 16:51
  • linux-ubuntu 18 – SKB Aug 30 '18 at 17:06
  • i got the solution in above answer i posted ....but got some warning issues when iwrite import sklearn the warning is - /home/sana/anaconda3/envs/my_env/lib/python3.7/site-packages/sklearn/utils/__init__.py:4: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working from collections import Sequence kindly help in this – SKB Aug 30 '18 at 18:48
0

final solution: first need activate the environment you are working and install conda package in that particular environment using conda install and do need not to install outside of your environment

sana@skb-linux:~$ . activate my_env
(my_env) sana@skb-linux:~$ conda install scikit-learn
Solving environment: done

so the sklearn package is installed in your particular environment(in my case its installed my_env)

Stephen
  • 8,508
  • 12
  • 56
  • 96
SKB
  • 771
  • 7
  • 14
0

I encountered the same issue on installing jupyter through conda, tried a lot of things, didn't work out. Finally, I remove it and re-installed it, worked fine this time, lol!!

  • Please don't add "thank you" as an answer. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation), you will be able to [vote up questions and answers](https://stackoverflow.com/help/privileges/vote-up) that you found helpful. - [From Review](/review/late-answers/31586880) – Zalhera Apr 24 '22 at 10:36