[英]Cannot import tensorflow_probability
When I try to import tensorflow_probability
, I get this error:当我尝试
import tensorflow_probability
时,出现此错误:
Traceback (most recent call last):
File "PATH", line 1, in <module>
import tensorflow_probability
File "PATH", line 75, in <module>
from tensorflow_probability.python import * # pylint: disable=wildcard-import
File "PATH", line 24, in <module>
from tensorflow_probability.python import edward2
File "PATH", line 32, in <module>
from tensorflow_probability.python.experimental.edward2.generated_random_variables import *
File "PATH", line 34, in <module>
from tensorflow_probability.python.experimental import auto_batching
File "PATH", line 24, in <module>
from tensorflow_probability.python.experimental.auto_batching import frontend
File "PATH", line 46, in <module>
from tensorflow.python.autograph.pyct import compiler
ImportError: cannot import name 'compiler' from 'tensorflow.python.autograph.pyct' (PATH)
I don't know why Python can't import this module because when I type pip list
in cmd, it tells me that I have tensorflow-probability 0.8.0rc0
installed.我不知道为什么 Python 无法导入此模块,因为当我在 cmd 中键入
pip list
时,它告诉我安装了tensorflow-probability 0.8.0rc0
。 Any help would be greatly appreciated.任何帮助将不胜感激。
I have tried to import in Google colab
and Ubuntu 18
version.我尝试在
Google colab
和Ubuntu 18
版本中导入。 In colab
it worked directly, in ubuntu I faced issues.在
colab
它直接工作,在 ubuntu 我遇到了问题。
Upgrading to the latest pip and TensorFlow version resolved my issue.升级到最新的 pip 和 TensorFlow 版本解决了我的问题。
Colab:合作实验室:
import tensorflow_probability as tfp
Ubuntu 18: Ubuntu 18:
Upgrade pip升级pip
pip install --upgrade pip
install the latest version of TensorFlow安装最新版TensorFlow
pip install tensorflow
install tensorflow_probability安装 tensorflow_probability
pip install --upgrade tensorflow-probability
tensorflow-probability version 0.11.1
张量流概率版本
0.11.1
Try to install the tf_agents
package.尝试安装
tf_agents
package。 I had a few import errors appear when trying to import tensorflow_probability
.尝试导入
tensorflow_probability
时出现了一些导入错误。 These include:这些包括:
module 'tensorflow.python.ops.linalg.linear_operator' has no attribute 'make_composite_tensor'
cannot import name 'all_util' from 'tensorflow_probability.python.internal'
. cannot import name 'all_util' from 'tensorflow_probability.python.internal'
。 These issues were resolved when I installed and imported the tf_agents
.当我安装和导入
tf_agents
时,这些问题得到了解决。
pip install --upgrade tf_agents
If you're using jupyter, add the following to a cell and then run it:如果您使用的是 jupyter,请将以下内容添加到单元格中,然后运行它:
import sys
!{sys.executable} -m pip install --upgrade tf_agents
Had the exact same problem.有完全相同的问题。 Removing older tensorflow version and installing everything nightly solved my problem .
删除较旧的 tensorflow 版本并每晚安装所有内容解决了我的问题。
pip uninstall tensorflow
pip uninstall tensorflow-probability
pip install tf-nightly
pip install tfp-nightly
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.