I have installed uvicorn from py -m pip install uvicorn, when I run uvicorn I get this error.
'uvicorn' is not recognized as an internal or external command,
operable program or batch file.
How can I make it to work, what am I doing wrong?
Could you please help
python version 3.7.3

This is a path issue probably. Make sure uvicorn exists in {PYTHON_INSTALLATION_DIR}\Scripts.
If it exists, add to your PATH environment variable that directory (https://docs.alfresco.com/4.2/tasks/fot-addpath.html)
I'd recommend trying this in a virtualenv (or any other dependency manager like poetry or pipenv)
This is how I ask people to setup their projects on my tutorials:
python -m venv .venv
source .venv/bin/activate
pip install uvicorn
uvicorn main:app --reload
I'm going to close this issue as I assume it has been correctly answered and resolved, but please feel free to reopen if you are still running into problems. Also please keep creating new questions, issues, bug reports, etc. as you run into them!
Thanks for all the help here everyone! :clap: :bowing_man: :cake:
This is a path issue probably. Make sure uvicorn exists in {PYTHON_INSTALLATION_DIR}\Scripts.
If it exists, add to your PATH environment variable that directory (https://docs.alfresco.com/4.2/tasks/fot-addpath.html)
I have tried this but still getting same error. please help
@ajay1013 can you tell us the contents of your PATH env var, and the location of the uvicorn executable?
@ajay1013 can you tell us the contents of your PATH env var, and the location of the uvicorn executable?
paths added to env are:-
C:\Users\dell\AppData\Roaming\Python\Python37\Scriptsuvicorn.exe
C:\ProgramData\Anaconda3\Lib\site-packages
also my main.py is located at C:\Users\dell.spyder-py3
Let me know if any other info is required
Can you tell us the exact steps you used to create your virtual environment? (which you should be using)
below steps are tried by me:-
1.) opened anaconda promt
2.) activate environment using conda activate cell
3.) redirected to the location of main.py using cd "C:\Users\dell.spyder-py3"
4.) used uvicorn main:app --reload
after these I have added the above environment variables as per above solution provided by aviram hassan.
You shouldn't manually modify your PATH - once you activate your cell, install your dependencies, then try running your app again
As per your suggestion i have tried the same way (activated environment, installed dependencies then tried to run the app) but now i am getting another error. Kindly refer to the attachment.
I suggest trying to run on a different port
If that doesn't help, try some of the solutions in this thread: https://stackoverflow.com/q/2778840/1433288
I suggest trying to run on a different port
If that doesn't help, try some of the solutions in this thread: https://stackoverflow.com/q/2778840/1433288
Hey, the issue is resolved. now I am able to launch it. Thanks a lot for your help. you are really awesome, thanks again.
Most helpful comment
I'd recommend trying this in a virtualenv (or any other dependency manager like poetry or pipenv)
This is how I ask people to setup their projects on my tutorials: