python - Import error 'PathLike' with TensorFlow in spyder -
i installed tensorflow in virtual enviroanment (virtualenv) on mac os x , seems work well. want use tensorflow in spyder. of community figured out write
import sys sys.path = [path tensorflow works fine in terminal]
at beginning of code in spyder, able perfom
import tensorflow tf
and "hello tensorflow!" code. when try more advanced code receive following error: "importerror: cannot import name 'pathlike'"
does know how resolve issue or know if related described workaround tensorflow working in spyder?
the error in detail: file "/users/myname/tensorflow/lib/python3.6/site-packages/tensorflow/tensorboard/plugins/projector/projector_plugin.py", line 22, in import imghdr
file "/library/frameworks/python.framework/versions/3.6/lib/python3.6/imghdr.py", line 3, in os import pathlike
importerror: cannot import name 'pathlike'
additional info: virtualenv 15.1.0 spyder 3.0.2 mac os 10.12.6
here example of file reproduces import error. example provided tensorflow , works when tried on different computer (windows).
import tensorflow tf import numpy np import matplotlib.pyplot plt rho = 28.0 sigma = 10.0 beta = 8.0/3.0 def lorenz_equation(state, t): x, y, z = tf.unstack(state) dx = sigma * (y - x) dy = x * (rho - z) - y dz = x * y - beta * z return tf.stack([dx, dy, dz]) def integrate(num): init_state = tf.constant([0, 2, 20], dtype=tf.float64) t = np.linspace(0, 50, num) tensor_state, tensor_info = tf.contrib.integrate.odeint( lorenz_equation, init_state, t, full_output=true) sess = tf.session() state, info = sess.run([tensor_state, tensor_info]) x, y, z = state.t plt.plot(x, z) plt.show() integrate(10000)
Comments
Post a Comment