0
我有这样的目录结构:导入包没有sys.path中
proj/
|- src/
|- org/
|- example/
|- dir/
|- foo.py
|- ...
|- src2/
|- org/
|- example/
|- dir/
|- bar.py
|- ...
我的问题是:如何导入foo
为bar
不使用sys.path
,如果可能,避免写一个__init__.py
文件在每个子目录src
?请注意,实际的.py文件只有在相关时才位于dir
文件夹中。
这就提出了一个'ModuleNotFoundError:无模块命名为“src''。 – norb