13

I followed instructions given in the TensorFlow website to install tensorflow_hub and installed it within a conda environment.

$ pip install "tensorflow>=2.0.0"
$ pip install --upgrade tensorflow-hub

I ran the above in anaconda prompt

enter image description here

But I'm still getting ModuleNotFoundError for 'tensorflow_hub'.

Any help here is appreciated. Thanks in advance

4
  • 1
    May be your're using multiple environments Commented Sep 14, 2020 at 13:02
  • Use python -m pip install --upgrade tensorflow-hub, and replace python with whichever python interpreter you want to use.
    – jkr
    Commented Sep 14, 2020 at 15:27
  • Hi Abhiram kadali, As Adam suggested, can you please confirm if you are importing tensorflow hub in the same virtual environment in which you have installed it. Thanks!
    – user11530462
    Commented Sep 17, 2020 at 15:39
  • I mean to say, please ensure that you are importing tensorflow_hub in your Virtual Environment, py3_TF2.0. If it is still resulting in error, please share your code.
    – user11530462
    Commented Sep 20, 2020 at 12:11

2 Answers 2

20

First thing Check whether you have installed tensorflow_hub within that environment

conda list

If you can not find it there, maybe you have been installing it to another environment which does not matter, just install it again here.

pip install tensorflow_hub

You have probably done that so most likely you are using another kernel within your jupyter notebook, so either go to the environment of that kernel and install your package there. Or the preferred way, install your current environment yourenvironment as a new kernel and use that one in your jupyter notebook

  python -m ipykernel install --user --name=yourenvironment

Now start your jupyter notebook and enjoy your package

2

Either downgrade tensorflow or upgrade tensorflow-hub, e.g.:

!pip install --upgrade tensorflow-hub

In jupyter notebook it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.