SoFunction
Updated on 2024-11-19

The solution to the reason why import is grayed out in pycharm.

1. Description of the problem:

When multiple files in the same directory have interdependencies with each other, import cannot recognize the module you wrote, and PyCharm prompts No Module.


2. Steps towards a solution:

(1). Open File-> Setting-> open the Python Console under Console and check the option (Add source roots to PYTHONPAT).


(2). Right click on your own workspace folder, find Mark Directory as select Source Root, problem solved!


According to the settings given above "right click on your workspace and look for Mark Directory as select Source Root", but it does not solve the problem, which means that it is not my files stored in a different channel (import files will first look in the same directory).


Here's the problem: I put two files with similar filenames under one source root at the same time, which might interfere, so the solution was:


Perfect solution, luck is all too real.

to this article on pycharm import grayed out reasons for the solution to this article, more related pycharm import package grayed out content please search for my previous articles or continue to browse the following related articles I hope you will support me more in the future!