导入错误:无法从“lib”

时间:2021-06-22 21:17:46

标签: python-3.x import package

如下图所示,我创建了一个TEST包,有两个子包(test1, test2),这是包的结构:

\test
   | __pycache__.py # ki importit lib fell main tcrea
   | __init__.py
   | lib.py
   | \test1
   |     | __init__.py
   |     | test1.py
   | \test2
   |     | __init__.py
   |     | test2.py

我想在 test1.py 中导入 lib 我已经尝试了下一个代码(正如我在教程中看到的那样):

import lib
lib.test()

# from lib import test
# test()

# from ..lib import test
# test()

我尝试使用 TEST 包中的 vs 代码 cmd 执行代码,然后我进入 test1 子包(cd .\test1)尝试,但没有奏效。 我收到了这些错误: enter image description here

感谢帮助!!

0 个答案:

没有答案