0

I'm working on a Python project where I have this folder structure:

enter image description here

I'm currently editing the operators.py file and I get this error when I try to import a class from the hooks.py file.

enter image description here

I really don't understand why I get this error since by putting the __init__.py file in the custom folder I should have turned it into a python module.

1
  • from dags.custom.hooks import TrediWSHook, try to write oath from the source directory Commented Sep 3, 2021 at 10:23

2 Answers 2

2

That sounds like a PyCharm issue, not actually Python. I assume dags is the root folder for your project. If that's the case, right click on it -> Mark Directory as -> Sources Root

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

it seems your operators.py file is int the same module as hooks, so :

from .hooks import TrediWSHook

3 Comments

It is in the same folder, so this solution won't work.
@PCM this solution works for me, so don't know why you say that.
Ok, my bad, but what the OP tried is similar - from custom.hooks ... is the same as from .hooks ... when they are in the same folder. So, that's why I said it won't make any difference

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.