'No module found error for every conda package in anaconda jupyter notebook

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



Solution 1:[1]

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)

Solution 2:[2]

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..

Solution 3:[3]

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!!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Stephen
Solution 2 Chandu codes
Solution 3 Nitish Sandhu