3
votes

When I call any function in python3.6, I get the error below; however, it works fine in python3.4. Any idea? import tensorflow as tf tf.Session() Traceback (most recent call last): File "", line 1, in AttributeError: module 'tensorflow' has no attribute 'Session'

Here is my System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Debian 8.7
  • TensorFlow installed from (source or binary): by pip3
  • TensorFlow version (use command below): 1.7.0
  • Python version: 3.6.5
  • CUDA/cuDNN version: cuda 9.0 and cudnn 7.0
  • GPU model and memory: K80, 12 GB
  • Exact command to reproduce: import tensorflow as tf tf.Session()
2
You probably have a file in your directory named tensorflow.pymiradulo
@miradulo well, there is nothing in the directory. In any directory or in jupyter I get same error.Afshin Oroojlooy
What does dir(tf) show you?miradulo
@miradulo Almost nothing: ['__doc__', '__loader__', '__name__', '__package__', '__path__', '__spec__'] In python3.4 it provides the whole list of APIs,Afshin Oroojlooy
@miradulo with the new version of python3.6 my problem is solved. I removed my previous python3.6 and installed the version. Then installed tensorflow and it works. Probably you can follow same path.Afshin Oroojlooy

2 Answers

1
votes

I meet the problem too. Reinstall TensorFlow solve my ploblem.

  pip uninstall tensorflow-gpu
  pip install tensorflow-gpu
0
votes

With the new version of python3.6 my problem is solved. I removed my previous python3.6 and installed the newest version. Then installed tensorflow through pip and it works.