在ubuntu上,我使用以下结构:
.
├── src
│ ├── __init__.py
│ └── main.py
└── test
├── __init__.py
└── test.py
main.py
包含以下函数:
def fun(x,y):
return x+y
而且test.py
from src.main import fun
print(fun(2,3))
我在目录daddy
中工作。所以pwd
打印daddy
当我尝试调用test.py
$ python3 test/test.py
Traceback (most recent call last):
File "test/test.py", line 1, in <module>
from src.main import fun
ModuleNotFoundError: No module named 'src'
我已经看过了与此相关的其他答案,但它们对我不起作用。。。主要是因为它们不像我的案例那样处理工作目录。
目前没有回答
相关问题 更多 >
编程相关推荐