没有名为 'tensorflow_probability' 的模块

No module named 'tensorflow_probability'

我需要使用 Tensorflow 和 Tensorflow_Probability。通过这些命令安装后: conda install tensorflow-probabilitypip install --upgrade tensorflow-probability ,我 运行 它在笔记本中:

import tensorflow_probability as tfp

但是 returns 这个错误:

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

ModuleNotFoundError: No module named 'tensorflow_probability'.

结果

pip list

如下(相关部分):

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

谁能帮我解决这个问题(我用的是 Win 10)?

你的版本是正确的,你的命令也是正确的。

似乎其他模块中的不一致导致了此问题。

运行 执行以下命令并重试:

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

参考资料: https://github.com/deepmind/graph_nets/issues/3 https://github.com/tensorflow/probability/issues/103

张量流概率 0.7.0 不兼容: 张量流 1.13.1 查看tensoflow-probability版本发布页面https://github.com/tensorflow/probability/releases

正确的解决方案是将 tensorflow 升级到 1.14.0 或将 tensorflow-probability 降级到 0.6.0

pip install -U tensorflow-probability==0.6.0

和之前的回答一样,你必须通过这个页面找到一个与你的TensorFlow版本兼容的版本:https://github.com/tensorflow/probability/releases