使用 Python 从不同的文件夹导入模块,该文件夹从同一文件夹导入模块

时间:2021-05-20 08:58:41

标签: python import module

我有以下情况。 在文件夹“scripts”中,我有两个 python 脚本,“master”和“dependent”。 Master首先从依赖导入几个函数和类来做某事。例如:

from dependent import blahblah


#does a function or a class

我还有一个上一级的脚本(在“scripts”文件夹所在的文件夹中),它从 master 导入东西。就这样开始

from scripts.master import whatever

但是出现问题是因为 master 导入依赖,我得到错误:

ModuleNotFoundError: No module named 'dependent'

我该如何解决这个错误?

0 个答案:

没有答案