seanzand
seanzand

Reputation: 35

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.

Versions:

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?

Thanks

Upvotes: 2

Views: 3853

Answers (1)

Guinther Kovalski
Guinther Kovalski

Reputation: 1929

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
jupyter-notebook

the next time.

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

!which python

Upvotes: 3

Related Questions