Reputation: 65
when I try to create an app in FastAPI using the command "uvicorn main:app --reload", I get this uvicorn command not found error. My python version is 3.8.9.
when I tried installing uvicorn using "pip install uvicorn". It is successfully installed and up to date. But giving command not found error. How can I work with uvicorn command?
Upvotes: 2
Views: 13236
Reputation: 12395
That is because your Python bin folder is not in your path. You first need to find out where your Python bin is located.
For example, I use a Mac with the latest macOS 13.3 and I use the pre-installed Python 3.9. It is installed in ~/Library/Python/3.9/
. When you run pip install
you can get that information from the site-packages
, e.g. after running pip install I see the result like ~/Python/3.9/lib/python/site-packages
then I can add ~/Python/3.9/bin
to my PATH.
Upvotes: 1
Reputation: 815
Run uvicorn as a module: python -m uvicorn main:app --reload
Upvotes: 6
Reputation: 121
I recommend adding more information such as whether you are installing it globally, to your user, in a virtual environment, or in a docker container.
In either case, as another user mentioned in a comment, the module is not being installed in the python path that it is lookin at.
If you have Python 2.7 installed, it is possible pip is installing it to that path and you may need to use pip3.
pip3 install uvicorn
Upvotes: 1
Reputation: 21
It cannot find your uvicorn installation. If you installed it in a virtual environment, you have to call it from that virtual env.
Upvotes: 0