The question about pylint Unable to import

I have a model module in my flask service, which I import under other py, such as from model.trip import xxx. Then use pylint to check the error Unable to import, but the program can be executed normally. Ask for advice on how to solve it.

Oct.14,2021

change the import method. (I don't know your specific directory structure, and I can't give specific suggestions.)

for example: the
directory structure is proj/agent/common . I want to import common.util into the .py file under the agent directory.

  • your way: from common.utils import xxxx runs fine, but pycharm red (probably similar to pylint error report? ).
  • relative import: from .common.utils import xxxx runs fine, and pycharm is not marked red.
  • absolute import: from proj.common.utils import xxxx runs fine, and pycharm is not marked red.

(a vegetable chicken. I hope all of you who pass by will not hesitate to comment on what you have said wrong. )

Menu