这是一个创建于 2472 天前的主题,其中的信息可能已经有所发展或是发生改变。
目录结构:
-- src
|-- mod1.py
|-- mod2
| |-- mod2.py
|-- sub
| |-- test2.py
|-- test1.py
test2.py 中导入模块 mod2 的调用方式如下:
import sys
sys.path.append("..")
from mod2.mod2 import *
运行后报错:
Traceback (most recent call last):
File "test2.py", line 3, in <module>
from mod2.mod2 import *
ImportError: No module named mod2
python 版本 2.6.6
找了一些资料没有查到跟我一样的问题,求大家帮忙看下是哪里的问题,多谢。
4 条回复 • 2018-01-05 10:41:19 +08:00
|
|
1
casparchen 2018-01-04 19:44:43 +08:00 via iPhone
|
|
|
2
whx20202 2018-01-04 19:51:31 +08:00
目测 1L 说的对,如果你没有那个文件的话
|