This error happens because of how Python resolves imports. If your project looks like:
repo/
├── src/
│ ├── __init__.py
│ └── test.py
then:
From the project root (repo/):
uvicorn src.test:app --reload
From inside src/:
uvicorn test:app --reload
uvicorn src.test:app only works when you run it from the directory that contains src.
Do you want to share what your folder structure looks like to better look into this?