macOS – command not found: uvicorn
Question:
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
Answers:
I resolved setting a virtual environment in the project directory and installed the dependencies in it.
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
I am tried to install uvicorn:
pip3 install uvicorn
then run this command:
python3 -m uvicorn main:app --reload
works.
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
I resolved setting a virtual environment in the project directory and installed the dependencies in it.
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
I am tried to install uvicorn:
pip3 install uvicorn
then run this command:
python3 -m uvicorn main:app --reload
works.