Follow all the steps below when initially setting up the server to run on your machine. Once you did this once, you shouldn't need to redo it and can just paste the run command, but if anything breaks, use the process below to debug
The assumption here is that you're using VSCode and have Python installed properly with the Python VSCode extension (all on Windows, should be similar for Mac but might be different in some ways)
- Close out of all VSCode terminals completely
- Open the Command Palette in VSCode by pressing Ctrl + Shift + P
- Type "interpreter" and find the option "Python: Select Interpreter"
- Press "Create Virtual Environment..."
- Press "Venv"
- Select whatever Python interpreter path appears (should only be one if you installed Python correctly, but if there's more, then select the latest, ideally 3.11+; if there's none, try installing Python again)
- Wait for the venv to finish being created, and then restart VSCode (important)
- Open the Command Palette again and type "interpreter", selecting the option "Python: Select Interpreter" again
- Select the option that says "Recommended" on the right (should be the path with "venv" in it)
- Open the terminal and start a Python shell by typing
python(if that doesn't work, trypython3orpy) - Enter
import sys - Enter
sys.prefix(after looking below exit withexit())
If the very end of the printed path says ".venv", then it worked
If not, make sure the venv is the selected interpreter, and that you restarted VSCode after selecting the interpreter
Now, any terminal you open in the project directory should be running the venv that is inside your project folder
In your VSCode terminal, run the following command (replace pip with pip3 if it doesn't work):
pip install -r requirements.txt
Run this too, uvicorn doesn't work unless I install this for whatever reason
pip install -U email-validator
- When you have the project open in VSCode, make sure you have all the dependencies installed from above
- Check your terminal to make sure you are CD'd into the projects root directory (make sure you are not in any folder such as testing, docs, databases, etc)
- Once you have verified everything above, use the explorer to databases > database_setup > UserDB_setup.py and open the file in your editor
- Run the file using the run button and the database should be set up correctly (if it doesn't work make sure you are running the file in the root project directory, hence step 2, or check dependencies/venv)
Just run
uvicorn main:app --reload
in your terminal (or actually you could run the file normally, I made it work)
To stop the app, just press Ctrl + C while terminal is selected
Run
pip install requests
in your terminal to allow the tester to make requests to your app
When running the Jupyter file for the first time:
- If asked to select an interpreter, use the same venv from before
- If then asked to allow the installation of "ipykernel", say yes