I have created a FastAPI app that is using the python library here
https://github.com/swar/nba_api
When I run the command
uvicorn main:app --reload
I get that the module nba_api is not found. I have installed this module using pip and am currently using a Python virtualenv (can see the nba_api in the lib/python3.10/site-packages file). When I just run the main.py file using
python3 main.py
the module is found. Any ideas why this would be the case?
Ran
uvicorn main:app --reload
was expecting my web server to load and to be able to hit the API endpoints that would use this python library, however uvicorn server failed to load.
Can call library if I invoke using
python3 main.py
                My crystal ball says you've installed uvicorn outside the virtualenv; if that's the case, uninstall it from the ambient environment, then install it only in the virtualenv, and try again.
.venv is sometimes behaving in a strange way. So, I think, if uvicorn was already installed previously, even if you installed it in the virtual environment, it picks up from the base/root environment.
So, uninstalling uvicorn package from base/root environment, and then installing it again in virtual environment should solve the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With