ModuleNotFoundError:没有名为' mypackage'

时间:2017-08-06 03:42:53

标签: python python-3.x module packages

parent_folder/
    __init__.py
    mypackage/
        __init__.py
        mymodule.py
    mycode/
        __init__.py
        mycode.py

mymodule.py:

def myfun():
    print("Hello world")

mycode.py:

from mypackage.mymodule import myfun  
myfun()

当我运行mycode.py时,ModuleNotFoundError:没有名为' mypackage'弹出。 有谁知道为什么?

0 个答案:

没有答案