ChineseNER icon indicating copy to clipboard operation
ChineseNER copied to clipboard

NameError: name 'os' is not defined

Open yyHaker opened this issue 8 years ago • 5 comments

Hello! I run your code , but found errors below:


Traceback (most recent call last): File "F:/yyhaker/software/project/NamedEntityRecognition/src/ChineseNER/main.py", line 225, in if name == "main": File "D:\perhack\Anaconda3\envs\my_pytorch\lib\site-packages\tensorflow\python\platform\app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "F:/yyhaker/software/project/NamedEntityRecognition/src/ChineseNER/main.py", line 219, in main clean(FLAGS) File "F:/yyhaker/software/project/NamedEntityRecognition/src/ChineseNER/main.py", line 114, in train # create maps if not exist NameError: name 'os' is not defined



I have install the os module, and it can run correctly! What's wrong with it?

yyHaker avatar Jan 04 '18 04:01 yyHaker

Oh, god! When I "import tensorflow as tf" before "import os", the code can run correctly! But when I "import tensorflow as tf" after "import os", it can't run correctly and give the above error, what's wrong with it?

yyHaker avatar Jan 04 '18 06:01 yyHaker

这个问题你解决了吗?

qinya avatar Jan 25 '18 08:01 qinya

@qinya 我在这两行之间加了几行空行就行了

# encoding=utf8


import os

KaqiKaqi avatar Feb 08 '18 09:02 KaqiKaqi

把# encoding=uft8去掉也可以,我不懂

weilonghu avatar May 25 '18 14:05 weilonghu

@yyHaker : thanks for your suggestions. same thing happened to me, and changing the import flow fixed it. not sure why!

fhn0 avatar Jun 04 '18 22:06 fhn0