Reputation: 182
When I try to import tensorflow_probability
, I get this error:
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. Any help would be greatly appreciated.
Upvotes: 3
Views: 6125
Reputation: 21
Try to install the tf_agents
package.
I had a few import errors appear when trying to import 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'
.These issues were resolved when I installed and imported tf_agents
.
pip install --upgrade tf_agents
If you're using jupyter, add the following to a cell and then run it:
import sys
!{sys.executable} -m pip install --upgrade tf_agents
Upvotes: 2
Reputation: 502
Had the exact same problem. Removing older tensorflow version and installing everything nightly solved my problem.
pip uninstall tensorflow
pip uninstall tensorflow-probability
pip install tf-nightly
pip install tfp-nightly
Upvotes: 0
Reputation:
I have tried to import in Google colab
and Ubuntu 18
version. In colab
it worked directly, in ubuntu I faced issues.
Upgrading to the latest pip and TensorFlow version resolved my issue.
Colab:
import tensorflow_probability as tfp
Ubuntu 18:
Upgrade pip
pip install --upgrade pip
install the latest version of TensorFlow
pip install tensorflow
install tensorflow_probability
pip install --upgrade tensorflow-probability
tensorflow-probability version 0.11.1
Upvotes: 1