How to solve the problem of not identifying the packages and modules written by yourself when importing in python

We use pycharm to open the code we wrote. When multiple files are interdependent, import cannot recognize the file we wrote, but the file we wrote is indeed in the same folder.

This kind of problem can be solved by the following methods:

1) Open File-"Setting -" Open the Python Console under the Console, and click on the option (Add source roots to PYTHONPAT)

2) Right-click on your workspace, find the Mark Directory as below and select Source Root to solve the above problem!

Guess you like

Origin blog.csdn.net/xiaohaigary/article/details/109071856