JavaEar 专注于收集分享传播有价值的技术资料

AttributeError: module 'tensorflow' has no attribute 'Variable' "ERROR"

I have used tensor-flow for ONE day, but there come some troubles, when I import tensor-flow, there would be AttributeError: 'module' object has no attribute 'variable'

I use Windows10, Python 3.5.3, Anaconda-3 4.4.0

here is my test code:

import tensorflow as tf
my_var = tf.Variable(tf.linspace(10.0, 13.0, 4)) 
with tf.Session() as sess:
    print (

I got this error: Error


  1. It looks like you have written a module,, which shadows the standard library's random module. Try renaming the file and check if the error goes away. You can tell it's importing your at the bottom of the stacktrace you posted.