Reputation: 193
I bought a MAC and I use this system for the first time, I also recently started using python. I have a python project with a requirement.txt file which I opened with PyCharm which also contains a dependency on uvicorn. I installed all the dependencies, but when I try to run the command "uvicorn main: app" I get the error "command not found: uvicorn". I tried to look for guides on my problem and I read that it could concern the PATH variable and following what written in these guides I tried to add the PATH to python from my home directory. Now the content of my python PATH is the following:
/Library/Python/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
I also read that I should have added the following line to my ~/.profile file and that because my MAC is a new one I could not have it, so I created this file and write the line written below:
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
nothing has changed since my attempts so I am asking what I should do. I've also seen that pip3 installed my modules of the requirements.txt file on the following directory:
/usr/local/lib/python3.7/site-packages/
Thank you in advance for your help
Upvotes: 6
Views: 13660
Reputation: 31
It worked for me when I added the virtual env and ran it with python3 (Trying FastAPI)
python3 -m venv env
source env/bin/activate
pip install -r requirements.txt
python3 main.py
Upvotes: 0
Reputation: 38631
I am tried to install uvicorn:
pip3 install uvicorn
then run this command:
python3 -m uvicorn main:app --reload
works.
Upvotes: 7
Reputation: 367
You can use the "-m"
in this case:
python3 -m uvicorn main:app --reload --port 50000
If this works, you can find your sever at localhost:50000
Upvotes: 12
Reputation: 193
I resolved setting a virtual environment in the project directory and installed the dependencies in it.
Upvotes: 1