简体   繁体   English

在 __init__.py [暂停] 中找不到引用“ref_name”

[英]Cannot find reference 'ref_name' in __init__.py [on hold]

I'm trying to make my own simple snake AI from this repository.我正在尝试从这个存储库中制作我自己的简单蛇 AI。 And I have such problem: my IDE underlines我有这样的问题:我的 IDE 下划线

from api import ping_response, start_response, move_response, end_response

saying that it cannot find reference ping_response , start_response etc in __init__.py .说它在__init__.py中找不到引用ping_responsestart_response等。 But those functions are defined in api.py .但是这些函数在api.py中定义。 And as far as I'm concerned they are imported from api .就我而言,它们是从api进口的。 Any help?有什么帮助吗?

change改变

from api import ping_response, start_response, move_response, 

to

from app.api import ping_response, start_response, move_response, 

and call your script from the top level directory with并从顶级目录调用您的脚本

python -m app.main

This should work.这应该有效。

You can also restructure your directories otherwise, but my suggestion could be a start您也可以以其他方式重组您的目录,但我的建议可能是一个开始

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

相关问题 在“__init__.py”中找不到参考“TextVectorization” - Cannot find reference 'TextVectorization' in '__init__.py' 在 __init__.py 中找不到引用“xxx” - Cannot find reference 'xxx' in __init__.py 为什么 pygame 在“__init__.py”中找不到引用“...”? - Why pygame cannot find reference '…' in '__init__.py'? 在“ __init __。py” Google自定义搜索API中找不到引用“发现” - Cannot find reference 'discovery' in '__init__.py' Google custom search API 安装 opencv 后,如何解决 python 中的“Cannot find reference 'imread' in '__init__.py”错误? - How to resolve this error of "Cannot find reference 'imread' in '__init__.py" in python after installing opencv? Tensorflow 可以在 Pycharm 中使用,但在 __init__.py 中找不到引用 `xxx` - Tensorflow can be used in Pycharm, but cannot find reference `xxx` in __init__.py Python 3 Opencv 设置问题:“在 __init__.py 中找不到引用‘VideoCapture’” on Pycharm IDE - Python 3 Opencv set up problem: "cannot find reference 'VideoCapture' in __init__.py" on Pycharm IDE Python ImportError:无法导入名称__init__.py - Python ImportError: cannot import name __init__.py Flask ImportError:无法导入名称(对于__init__.py中的应用程序) - Flask ImportError: cannot import name (for app in __init__.py) __init__.py 中的 __name__ 是什么? - What's __name__ in the __init__.py?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM