python - Python - ImportError: cannot import name - another question
问题描述
I've seen dozens of questions like this with different problems / solutions. After going through the first dozen or so on StackOverflow, I haven't found a solution to my problem which is:
I have a class like this:
class Flight:
pass
in a file called airtravel.py
and then on my REPL (in that directory) I use:
from airtravel import Flight
which immediately fails with:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name Flight
>>>
Any suggestions?
解决方案
您可以尝试以下建议,看看是否有帮助。
- 您的文件的最新内容可能
airtravel.py
未保存。 - 尝试将您的文件重命名
airtravel.py
为其他名称说airtraveltest.py
推荐阅读
- angular - nrwl nx 应用程序(Angular7 / Typescript)之间的共享样式(scss)
- groovy - 从 JSON 获取 Groovy 输出 XML
- rest - Kotlin +spring boot post请求默认布尔值
- vsix - 在 Visual Studio 上的构建后事件属性上写入新值
- python - Python,用箭头键移动物体
- c# - 继续当前对话框的 Microsoft Bot Framework 主动消息
- php - WooCommerce:在购物车/迷你购物车中显示产品总价而不是产品价格
- python - 如何从数组中消除特定行?
- layout - 在 Flutter 中,如何使用 FittedBox 调整行内文本的大小?
- flatbuffers - Flatbuffers:用字节而不是布尔设置的表布尔值