0

I am exploring the use of Poetry for packaging my Python's applications.

I started using Poetry on an already existing project. The structure is like this :

├─ bin
|  └─ main.py
├─ docs
├─ data
├─ src
│  └─ packagename
│     ├─ __init__.py
│     └─ ...
├─ tests
│  └─ ...
└─ pyproject.toml

I had a virtualenv already set up. So I executed the following commands to Poetry:

poetry init (inside the package directory)
poetry add *package lists*

I checked Poetry is recognizing the virtualenv with the command :

poetry env info 

and this gave the expected result.

So now, I would like to test my package i.e. run the main.py script which does (among other things):

import packagename

To achieve this, I executed :

poetry install
poetry run bin\main.py

but the poetry run command throws a ModuleNotFoundError : No module named 'packagename'. What am I not understanding/doing wrong ?

FenryrMKIII
  • 1,068
  • 1
  • 13
  • 30
  • What is the whole error message for the `ModuleNotFoundError`? – sinoroc Nov 15 '20 at 15:41
  • I updated the question. It simply states that there is no module named 'packagename' – FenryrMKIII Nov 15 '20 at 16:23
  • 2
    Do you mind showing the `pyproject.toml`? At least we need to know if the project name and top level package name are somewhat conventional, otherwise _poetry_ can not pick it up automatically. If for whatever reason the package name is not a normalized version of the project name, then you can always use the `include` setting of `pyproject.toml`. – sinoroc Nov 15 '20 at 16:50

0 Answers0