1

I have an api with a structure like this

my-api
├── Dockerfile
├── __init__.py
├── app
│   ├── __init__.py
│   ├── api
│   │   ├── __init__.py
│   │   └── mymodule.py
│   ├── config.py
│   ├── main.py
│   └── requirements.txt
└── docker-compose.yml

I'm trying to import mymodule.py into main.py per the docs but when I do so get the error

File "./app/main.py", line 3
from my-api.app.api import allocate
       ^
SyntaxError: invalid syntax

My import looks like this

from my-api.app.api import mymodule

and my Dockerfile CMD is

CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7833"]

Is there something I'm doing wrong here?

CEamonn
  • 853
  • 14
  • 37
  • 4
    `my-api` isn't a valid python module name. Modules cannot have a `-` in them: https://stackoverflow.com/questions/7583652/python-module-with-a-dash-or-hyphen-in-its-name – match May 18 '20 at 10:08
  • @match that was it, thanks! – CEamonn May 18 '20 at 10:39

0 Answers0