Poetry cannot import from subfolders with "poetry run"

Viewed 24

Project structure is like this:

.
├── README.md
...
(snip)
...
├── moduleA.py
├── moduleB.py
└── FolderC
    └── moduleC.py

moduleA.py:

from .moduleB import moduleB_func
from .FolderC.moduleC import moduleC_func
...

script in pyproject.toml:

funcA_run = my_project_name.moduleA:funcA

(funcA function is just example - exception appears on start of compiling at the second line on import)

If i type poetry run funcA_run in project directory (where my_project_name folder, readme.rst, pyproject.toml and other poetry files), moduleB imports successfully, but moduleC from subfolder is not:

ImportError: cannot import name 'moduleC_func' from 'FolderC' (unknown location)

Removing . from import doesn't help.

With import FolderC.moduleC.moduleC_func i getting

ModuleNotFoundError: No module named 'FolderC.moduleC_func'

If moduleC.py import would be in moduleB.py, same will happen.

So, because of this i can't run any scripts, that contains local relative imports from my project.

Poetry version is 1.1.14

0 Answers
Related