No module named 'tensorflow_probability'
Asked Answered
P

3

13

I need to use Tensorflow and Tensorflow_Probability. After installing it by these commands: conda install tensorflow-probability or pip install --upgrade tensorflow-probability , I ran it in the notebook:

import tensorflow_probability as tfp

but it returns this error:

    ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-8-41494c8c96ff> in <module>
----> 1 import tensorflow_probability as tfp

ModuleNotFoundError: No module named 'tensorflow_probability'.

The results of

pip list

is as below (related parts):

tblib                              1.3.2
tensorboard                        1.13.1
tensorflow                         1.13.1
tensorflow-estimator               1.13.0
tensorflow-probability             0.7.0
termcolor                          1.1.0
terminado                          0.8.1
testpath                           0.4.2
tfp-nightly                        0.8.0.dev20190708
Theano                             1.0.4
toolz                              0.9.0

Can anyone help me to solve this problem (I am using Win 10)?

Pollaiuolo answered 8/7, 2019 at 13:21 Comment(2)
on which enviorment are you loading it? the import command?Regnal
@Regnal I have "base" environment and also my defined environment "TensorFlowEnv". The output of "pip list" seems to be from the defined environment.Pollaiuolo
T
11

Your versions are correct and your command is correct too.

Seems like inconsistency in other module is causing this.

run the following commands and try again:

pip install -U dm-sonnet==1.23
pip install --upgrade tfp-nightly

References: https://github.com/deepmind/graph_nets/issues/3 https://github.com/tensorflow/probability/issues/103

Torquemada answered 8/7, 2019 at 13:35 Comment(3)
Thanks a lot, it works now. The "sudo" is a Linux function and I used the windows version of the second command.Pollaiuolo
Note you also had two versions of TFP installed -- tensorflow-probability (stable, versioned) and tfp-nightly (built and released nightly, less stable). TFP nightly may work with TF stable (especially since TF just released 1.14 pretty recently), but in general if you're using tfp-nightly you should also be using tf-nightlyFlowerless
@Pollaiuolo happy you could find a solution!Courtneycourtrai
S
6

tensorflow-probability 0.7.0 is not compatible with: tensorflow 1.13.1 check the tensoflow-probability version release page https://github.com/tensorflow/probability/releases

Correct solution will be either to upgrade tensorflow to 1.14.0 or downgrade tensorflow-probability to 0.6.0

pip install -U tensorflow-probability==0.6.0
Smoulder answered 13/10, 2019 at 6:20 Comment(0)
L
1

As the previous answer, you have to find a version compatible with your TensorFlow version through this page: https://github.com/tensorflow/probability/releases

Leisure answered 29/3, 2021 at 1:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.