2016-08-14 76 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即可。应该为你制造诡计。