0

I got issue with relative and absolute imports with PyCharm

Project structure:

enter image description here

When I'm trying to import a local Package like this I'm getting error

enter image description here

But this works fine: enter image description here

What should be done so that both PyCharm and Python do not give out an error?

loliallen
  • 106
  • 1
  • 7

1 Answers1

1

For PyCharm to recognize a directory as a module, you need to mark it as a Sources Root. To do that, right click it, hover over "Mark Directory as" and click on "Sources Root".

Xeoth
  • 1,285
  • 1
  • 11
  • 22
  • The problem with this is that you aren't installing you project. So the code you are testing and implementing will work differently from when you install it. – bad_coder Jan 08 '21 at 01:38