python文件运行报错:UnboundLocalError: local variable 'status' referenced before assignment
2017-09-08 18:22
896 查看
目录
问题描述
出现该问题的原因
解决办法
tensorflow 1.3 CPU版
运行python文件时报错,如下:
一般在编译python文件后,会生成
如下图中,我运行了training.py文件,该文件中import另外两个文件model.py和input_data.py,所以生成了这两个文件的.pyc文件。
问题描述
出现该问题的原因
解决办法
问题描述
python 3.5tensorflow 1.3 CPU版
运行python文件时报错,如下:
Exception ignored in: <bound method BaseSession.__del__ of <tensorflow.python.client.session.Session object at 0x1201ab940>> Traceback (most recent call last): File "/Applications/anaconda/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 581, in __del__ UnboundLocalError: local variable 'status' referenced before assignment
出现该问题的原因
这是因为在编译时,只删除了.pyc文件,留下了
__pycache__文件夹。
一般在编译python文件后,会生成
__pycache__文件夹,其中包括你import的其他python文件生成的
.pyc文件。
如下图中,我运行了training.py文件,该文件中import另外两个文件model.py和input_data.py,所以生成了这两个文件的.pyc文件。
解决办法
再次编译training.py文件(你的python文件)时,应该把__pycache__文件夹整个删除。
相关文章推荐
- Python 读写当前路径下文件错误 UnboundLocalError: local variable 'file' referenced before assignment
- python:UnboundLocalError: local variable 'l' referenced before assignment
- Python全局变量global和局部变量 UnboundLocalError: local variable 'x' referenced before assignment
- 【Python】UnboundLocalError: local variable 'x' referenced before assignment
- 全局变量报错:UnboundLocalError: local variable 'l' referenced before assignment
- 全局变量报错:UnboundLocalError: local variable 'l' referenced before assignment
- Python的UnboundLocalError: local variable 'xxx' referenced before assignment
- 【Python】UnboundLocalError: local variable 'l' referenced before assignment
- 全局变量报错:UnboundLocalError: local variable 'l' referenced before assignment
- python的UnboundLocalError: local variable 'xxx' referenced before assignment
- python 错误--UnboundLocalError: local variable '**' referenced before assignment
- Python - UnboundLocalError: local variable referenced before assignment
- python的UnboundLocalError: local variable 'xxx' referenced before assignment
- 全局变量报错:UnboundLocalError: local variable 'l' referenced before assignment
- Python的UnboundLocalError: local variable 'xxx' referenced before assignment
- 【Python基础】Python3: UnboundLocalError: local variable 'num' referenced before assignment
- Python问题:UnboundLocalError: local variable 'xxx' referenced before assignment
- UnboundLocalError: local variable 'epoch_logs' referenced before assignment
- UnboundLocalError: local variable 'c' referenced before assignment
- 【Python】UnboundLocalError: local variable 'l' referenced before assignment