错误一
AttributeError: module 'scipy.misc' has no attribute 'imread'
出现此错误的原因在于scipy与pillow没有安装或者版本不正确。
如果使用的pycharm编写代码,那么可以直接在pycharm里安装scipy(如果之前已经安装过,但是版本不对,那么直接点install package进行安装覆盖旧版本即可),这里版本要选择1.1.0
如果没有使用pycharm进行开发,那么可以以下指令安装scipy
pip install scipy==1.1.0
此外还需要安装pillow,安装最新的版本即可
pip install Pillow
错误二
AttributeError: module 'tensorflow' has no attribute 'assign'
AttributeError: module 'tensorflow' has no attribute 'global_variables_initializer'
出现以上错误的原因是因为使用的tensorflow版本过高,新版本的tensorflow中assign和global_variables_initializer的调用方式与旧版本不同。这里建议直接重新安装旧版本的tensorflow。
建议安装版本是1.4.0,但是在pycharm里提供的默认下载源里,1.4.0已经不提供下载了。这里可以安装1.13.0rc1版本
错误三
DLL load failed: 找不到指定的模块
出现这个问题的原因可能有很多种。
常见的原因是python的环境变量配置问题,如果这里使用的是python那么请检查python的环境变量配置情况。如果使用的是Anacond,也同理检查环境变量的配置。
也可在Pycharm内部添加环境变量,Run > Edit Configurations > Environment Variables,添加PATH=${Anaconda的根路径}\Library\bin
详细操作可参考此处
错误四
TabError: inconsistent use of tabs and spaces in indentation
IndentationError: expected an indented block
python是一门对缩进非常敏感的语音。出现缩进误用或者tab与空格混用的情况便会出现如上错误。
本实验提供的代码中有tab与空格混用的现象,在复制时请做好处理。
pycharm会自动对缩进不规范的地方进行标记。
这里可以将鼠标放在黄色的方形标记上,然后选择Convert indents to spaces
pycharm便会自动帮我们将tab转换为空格