2016-08-14 80 views
3

說,在不承認其他文件,我的項目結構如下:Pycharm進口相同的模塊

project_folder: 
    __init__.py 
    another_folder: 
    __init__.py 
    main_file.py 
    other_file.py 

而且main_file.py包含下面的代碼:

import other_file as whatever 

PyCharm(PEP8)強調此行作爲錯誤「no module named other_file」,並且在諸如whatever.this_should_be_autoc_suggested之類的任何呼叫上都沒有自動完成功能。同時口譯員工作得很好。

這種煩人的行爲的原因是什麼?

回答

2

您需要將項目目錄標記爲「Sources Root」,只需右鍵單擊pycharm中的目錄,將Mark Directory as,Root Root即可。應該爲你製造詭計。