简体   繁体   中英

Getting Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'filename' is not defined

When running a script containing this code:

print('Hello world')

I get this error message:

Traceback (most recent call last):   
  File "<stdin>", line 1, in <module> 
NameError: name 'filename' is not defined

I have double checked that I am in the current working folder ( os.getcwd() ).

What could be wrong?

I think it's better to use Command Prompt to run python file.

Go to your current directory that contains python file and open Command Prompt. Run your python file as "python filename.py".

That will be good.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM