可以说,我有一个看起来像这样的目录树:如何从同一程序中的不同目录中导入程序包?
main -
|
lib-
|
core-
|
fun-
|
some_file
stuff-
|
another_file
我怎么能导入从some_file
模块加入another_file
?每次我尝试做进口(是的,我知道__ init__.py
)我得到一个错误:
Traceback (most recent call last):
File "file.py", line 6, in <module>
from some_file import some_method
ImportError: No module named some_file
是否可以将模块导入到另一个文件?
你可以显示你如何尝试导入模块的代码 – depperm
@depperm没有办法使用'os.path.join'来做到这一点吗? – User9123