从python中的同一文件夹导入失败

时间:2018-08-20 23:00:17

标签: python import

我有一个文件夹:locust_runner。其中有两个文件:locust_runner.pylocust_maker.py。在locust_maker.py中,我要导入在locust_runner中定义的所有内容。

如果我这样做:

from .locust_runner import *

没有突出显示表明这是错误。但是,如果我运行它,则会得到:

SystemError: Parent module '' not loaded, cannot perform relative import

我尝试了from locust_runner import locust_runner的其他所有组合以及我能想到的所有其他方法,但是没有任何效果。如何使它起作用?

0 个答案:

没有答案