[英]Python- no module named error. wherever i place the __init__.py file the ingestor file just cant seem to get at it
project structure
__init__.py
backend
__init__.py
/log_parser.py
/ingestor
/data_aggregation
configuration
scripts
__init__.py(holding create_app and db)
UI
utils
/__init__.py
/models
日志解析器内部是这个导入
from ingestor import Ingestor
但是每当摄取器文件到达这里
from scripts import create_app, db
它失败并显示错误消息
ModuleNotFoundError:没有名为“脚本”的模块(venv)
我尝试更改init .py 文件所在的目录,但没有成功。 我也尝试过导入目录中的所有内容,但也失败了。 所以我没有想法?
如果使用“/”,则表示__init__.py
和 ingestor 位于同一文件夹中。 确保在这个(摄取文件夹)中有外部__init__.py
文件,然后重试。
如果是,但总是面临同样的问题,请尝试这样的相对导入: from.ingestor import Ingestor
。 不要错过“摄取”之前的“点”
如果它不起作用,请尝试最后一个:
import sys
sys.path.append(".")
from ingestor import Ingestor
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.