Python package built with poetry can't find modules

Viewed 2642

I have built a package with poetry using poetry build.

This is the structure:

├── pyproject.toml
├── ...
└── some_project
    ├── main.py
    ├── options.py
    ├── helpers.py
    └── ...

Inside main.py I import two modules

from options import some_method
from helpers import some_other_method

Which runs fine locally with python, however when built with poetry and ran throws this error:

Traceback (most recent call last):
  File "/usr/local/bin/someproject", line 5, in <module>
    from some_project.main import main
  File "/usr/local/lib/python3.9/site-packages/some_project/main.py", line 4, in <module>
    from options import some_method
ModuleNotFoundError: No module named 'options'

Also worth mentioning I have this in my pyproject.toml:

packages = [
    { include = "some_project" },
    { include = "some_project/**/*.py" },
]

[tool.poetry.scripts]
someproject = 'some_project.main:main'

Would anyone know what has gone wrong here? Or maybe I have configured something wrong?

1 Answers

you should write from some_project.options import some_method in your main.py

Related