Tensorflow+python3 常见运行问题及其解决方法
本文地址:http://blog.csdn.net/shanglianlm/article/details/79390615
1 SyntaxError: Missing parentheses in call to ‘print’#
解决:python2支持 print “xxxx” ,python3需要使用print(“xxx”)
2 SyntaxError: multiple statements found while compiling a single statement#
解决:多行代码直接在IDLE中编译,是每行都要回车的,或者新建一个py文件来运行。
3 ImportError: Could not find ‘cudart64_90.dll’.
ImportError: Could not find ‘cudart64_90.dll’. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 9.0 from this URL: https://developer.nvidia.com/cuda-toolkit
解决:tensorflow只支持cuda9.0,下载9.0并安装。
4 ImportError: No module named ‘utils’#
解决:pip install utils
5 NameError: name ‘xrange’ is not defined#
解决:Python3中xrange改为range
6 ImportError: No module named ‘input_data’#
解决:解决:下载input_data或者使用tensorflow自带的input_data
from tensorflow.examples.tutorials.mnist import input_data
7 ValueError: Cannot evaluate tensor using eval()#
ValueError: Cannot evaluate tensor using eval()
: No default session is registered
解决:根据提示添加参数sess(sess为自己定义的Session名称):
train_accuracy = accuracy.eval(feed_dict={x:batch[0], y_: batch[1], keep_prob: 1.0})
修改为:
train_accuracy = accuracy.eval(session=sess,feed_dict={x:batch[0], y_: batch[1], keep_prob: 1.0})
8 ValueError: Cannot execute operation using run()#
ValueError: Cannot execute operation using run()
: No default session is registered. Use with sess.as_default():
or pass an explicit session to run(session=sess)
解决:根据提示添加参数sess(sess为自己定义的Session名称)
train_step.run(feed_dict={x: batch[0], y_: batch[1], keep_prob: 0.5})
修改为:
train_step.run(session=sess, feed_dict={x: batch[0], y_: batch[1], keep_prob: 0.5})
9 Import cv2 ImportError:DLL load failed#
Import cv2 ImportError:DLL load failed:找不到指定模块
解决方法:
1.首先保证有Visual C++ Redistributable for Visual Studio 2015,如果没有可以去官网下载:
https://www.microsoft.com/en-us/download/details.aspx?id=48145,
2.将python3.dll复制到Anaconda3目录中,具体操作为:
首先下载python包,下载地址为:https://www.python.org/ftp/python/3.5.2/python-3.5.2-embed-amd64.zip,解压后得到python3.dll, 将python3.dll复制到Anaconda3目录中,
来自:https://blog.csdn.net/u012318074/article/details/78840747
10 Exception ignored in: ‘_pydevd_frame_eval.pydevd_frame_evaluator_win32_36_64.get_bytecode_while_frame_eval’
更多推荐
所有评论(0)