PyCharm error: 'No Module' when trying to import own module (python script)

前端 未结 14 1843
醉话见心
醉话见心 2020-12-07 07:57

I have written a module (a file my_mod.py file residing in the folder my_module). Currently, I am working in the file cool_script.py t

14条回答
  •  天涯浪人
    2020-12-07 08:10

    Always mark as source root the directory ABOVE the import!

    So if the structure is

    parent_folder/src/module.py

    you must put something like:

    from src.module import function_inside_module

    and have parent_folder marked as "source folder" in PyCharm

提交回复
热议问题