Why doesn’t Pycharm recognize the modules and classes created by the user?

Asked

Viewed 3,266 times

-1

Hello, I’m new to python and have recently started working with the Pycharm IDE Community version. About the IDE, I liked it a lot, one of the best IDE’s I’ve ever used. However one problem I identified in it is that it does not recognize the modules or classes created by the user, maybe for it to do this automatically needs to be made some configuration before I have done. Basically, I create the module or class and when I import into another file, the IDE does not recognize, the module name is underlined red and when I try to write some module function to call it, the function does not appear in auto-complete. While not recognizing, the modules/classes work smoothly, you just need to type everything manually without errors that although the IDE does not recognize, it performs perfectly. I wonder if anyone’s ever had a similar problem before and solved it. Do I need to make any settings for the IDE to automatically recognize? Thank you in advance for your patience.

1 answer

1


Really this is a peculiarity of Pycharm, you need to inform Pychar that in the directory where your codes are there are also modules that can be imported.

To do this just right-click on the folder where your codes are and go to the "Mark Directory as" option and click on the "Sources Root" option. That will be enough for you to accomplish the Imports of the modules you create.

  • Man, you really fixed my problem. Sorry I didn’t see your answer before, I went a while without accessing Stackoverflow. Thanks anyway.

  • Not at all, friend, as you can see I also spent some time here without entering Stackoverflow

Browser other questions tagged

You are not signed in. Login or sign up in order to post.