title: Python, fastAPI, uvicorn - Error loading ASGI app. Could not import module "main"
body: <p>I am having trouble with getting uvicorn to start. I am very new to python and fastapi so I am assuming I have doing something very silly.</p>
  <p>I have isolated the problem to being in my api_router.py file</p>
  <pre><code>from fastapi import APIRouter
  from API.endpoints import user_endpoints
  
  api_router = APIRouter()
  
  api_router.include_router(user_endpoints, prefix=&quot;/user&quot;, tags=[&quot;User&quot;])
  
  </code></pre>
  <p>When I comment out from API.endpoints import user_endpoints and
  api_router.include_router(user_endpoints, prefix=&quot;/user&quot;, tags=[&quot;User&quot;]), the error does not occur. Am I trying to import my user_endpoints.py file incorrectly? I have attached an image of the directory structure.</p>
  <p>user_endpoints.py looks like this:</p>
  <pre><code>from fastapi.routing import APIRouter
  from typing import Optional, List
  from API.schema.user import User
  from models.user import Users
  from main import db
  
  router = APIRouter
  
  @router.get('/users', response_model=List[User], status_code=200)
  def get_all_users():
      users=db.query(Users).all()
      return users
  
  @router.get('/users/{user_id}')
  def get_user(user_id):
      pass
      
  @router.post('/users')
  def create_user():
      pass
  
  @router.put('/users/{user_id}')
  def update_user(user_id):
      pass
  
  @router.delete('/users/{user_id}')
  def delete_user(user_id):
      pass
  </code></pre>
  <p><a href="https://i.stack.imgur.com/pgMwh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pgMwh.png" alt="enter image description here" /></a></p>
  <p>Any help with this would be greatly appreciated.</p>
  <p>Thanks,</p>
  <p>Greg</p>