PyCharm "mark directory as sources root" allows import from local folder but script fails to import

Viewed 53

I have a Python 3.8 project with two files: src/utils/adder.py and src/main/addition_handler.py. I use mark root directory as on src.

adder.py

class MyAdder:
    def __init__(self, name='human', age=0):
      pass

    @staticmethod
    def add(a,b):
        return a+b

addition_handler.py

from utils.adder import MyAdder
print(MyAdder.add(8,2340))

addition_handler.py runs as expected in PyCharm, but fails in console.

from utils.adder import MyAdder
ModuleNotFoundError: No module named 'utils' 

How to fix this?

0 Answers
Related