0

I have an issue with using source package in PyCharm. Project structure looks like this

- project 
  - source
    - endpoint / user / _get / module1.py
    - layer / common / module2.py
  - tests
    ...

module2.py:

def somefunction():
  return 'sometext'

module1.py

import common

print(common.module2.somefunction())

In PyCharm preferences, under project structure i added source and source/layer as sources. In editor everything is correct, common package is visible, but when I run

python module1.py

It is showing

ModuleNotFoundError: No module named 'common'
psowa001
  • 725
  • 1
  • 6
  • 18
  • Recommended practice is adding an `__init__.py` in every directory and using absolute qualified names in the imports. Otherwise chances are you'll be having problems with cyclic imports latter. See [PEP 395](https://www.python.org/dev/peps/pep-0395/). – bad_coder Sep 03 '21 at 11:57

1 Answers1

1

Create a __init__.py files inside layer and common.

eagr
  • 58
  • 7