简体   繁体   English

获取回溯(最近一次调用最后一次):文件“<stdin> &quot;,第 1 行,在<module> NameError:名称“文件名”未定义

[英]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() ).我已经仔细检查了我是否在当前的工作文件夹中( os.getcwd() )。

What could be wrong?有什么问题?

I think it's better to use Command Prompt to run python file.我认为最好使用命令提示符来运行 python 文件。

Go to your current directory that contains python file and open Command Prompt.转到包含 python 文件的当前目录并打开命令提示符。 Run your python file as "python filename.py".将您的 python 文件作为“python filename.py”运行。

That will be good.那会很好。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 回溯(最近调用最后):文件“<stdin> “,第 1 行,在<module> NameError:名称“游泳”未定义</module></stdin> - Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'swim' is not defined 回溯(最近调用最后):文件“<stdin> ",第 1 行,在<module> NameError: 名称 'db' 未定义</module></stdin> - Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'db' is not defined 无法在python 3Traceback(最近一次调用为最新)中找出此错误:“文件” <stdin> ”,第1行,在 <module> NameError:未定义名称“ xlrd” - Cannot figure out this error in python 3Traceback (most recent call last): File “<stdin>”, line 1, in <module> NameError: name 'xlrd' is not defined Traceback(最近一次调用最后一次):,第 131 行,在<module> print(self.marka) NameError: name 'self' is not defined</module> - Traceback (most recent call last): , line 131, in <module> print(self.marka) NameError: name 'self' is not defined 追溯(最近一次通话):“文件” <stdin> ”,第1行,在 <module> - Traceback (most recent call last): File “<stdin>”, line 1, in <module> 追溯(最近一次通话最后一次):NameError:未定义名称“路径” - Traceback (most recent call last):NameError: name 'path' is not defined 获取回溯(最近一次调用最后一次):main() NameError:未定义名称“main” - getting Traceback (most recent call last): main() NameError: name 'main' is not defined Traceback(最近一次调用最后一次):文件“<stdin> ”,第 1 行,在<module> ModuleNotFoundError:没有名为“Webhook”的模块</module></stdin> - Traceback (most recent call last): File “<stdin>”, line 1, in <module> ModuleNotFoundError: No module named 'Webhook' Traceback(最近一次通话最后一次):文件“<stdin> &quot;,第 1 行,在<module> TypeError: object() 没有参数 - Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: object() takes no parameters 我可以逃避此错误回溯(最近一次通话是最近一次):“文件” <stdin> ”,第1行,在 <module> 档案“ <stdin> ”,第2行,在data_entry中 - can i escape this error Traceback (most recent call last): File “<stdin>”, line 1, in <module> File “<stdin>”, line 2, in data_entry
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM