Not able to import Tensorflow in Jupyter Notebook


I’m trying to import the Tensorflow module in my Jupyter notebook in a conda environment, but I get the following error:

AttributeError: type object 'h5py.h5.H5PYConfig' has no attribute '__reduce_cython__'

However, if I open Anaconda Prompt, activate the same enviroment and import tensorflow in the shell, it does work.


  • tensorflow-gpu: 2.2
  • h5py: 2.10

I tried downgrading to different versions (h5py 2.7 and tf-gpu 2.1), but that resulted in a lot more errors of conflicting versions of packages.

Does anyone have an idea why Jupyter is not loading the module and why it is working within the Anaconda shell?



Your jupyter notebook is probably running from the base environment. This can happen if jupyter notebook is installed in base but not in your current env.

Open Anaconda Navigator with anaconda-navigator, navigate to Environments and active your env, navigate to Home and install jupyter notebook, then lunch jupyter notebook from the navigator.

After doing this for the first time, you can just do:

source activate your_env

the next time.

Also you can check the python running inside jupyter with command:

!which python

Answered By – Guinther Kovalski

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published