This section is to outline the process of setting up a virtual enviornment (venv) for the STEP_TIME_BIOFEEDBACK project. Note: this process will vary depending on the operating system you are using so ensure you navigate based on which operating system you're working on.
First ensure you have python installed on your local computer. If you have python installed one of the following commands should return the specific version of python you have:
python --version
After make sure you have the virtualenv package installed with the following command:
pip install virtualenv
or
# if pip doesn't work you may have to specify version
# if you had python3 you would do pip3 install virtualenv
pip<version> install virtualenv
where version is the number that corresponds to the version of python you have.
After installing virtualenv we can run the following command to create your new virtual enviornment called env:
virtualenv env
and a folder should be created called env in your root project directory.
Before activating the virtual enviornment ensure you are in the root project directory STEP_TIME_BIOFEEDBACK.
To activate the virtual enviornment on MacOS or Linux use the source command as follows:
$ source env/bin/activate
To activate the virtual enviornment on Windows the commands differ depending if you're using Powershell or cmd.exe, specified below:
# For cmd.exe
env/Scripts/activate.bat
# For Powershell
env/Scripts/Activate.ps1
If your virtual enviornment is activated you should see the following all the way the left in your terminal:
(env)
After activating your virtual enviornment make you should make sure you have the correct dependencies installed. Ensure your virtual enviornment is activated when running the following command to install the correct dependences from the requirements.txt file:
Reminder: Ensure your virtual enviornment is activated before installing your dependencies. Otherwise, they will be installed globally, not inside the virtual enviornment
pip install -r requirements.txt
or
# if pip doesn't work you may have to specify version
pip<version> install -r requirements.txt
If you need to undo the global installation you can unistall the dependencies that were unstalled globally using the following command:
pip uninstall -r requirements.txt
or
# if pip doesn't work you may have to specify version
pip<version> uninstall -r requirements.txt
To deactive the virtual enviornment type deactivate in your terminal like below:
deactivate
If you install dependencies and need to update the requirements.txt file you can either manually update it in the requirements.txt file or you can use the command below:
However, be very careful when using the following command as it will override anything currently in the requirements.txt file.
pip freeze < requirements.txt
or
# if pip doesn't work you may have to specify version
pip<version> freeze < requirements.txt
Please ensure that you don't remove env/ from the gitignore file so you don't push your local virtual enviornment to the repository.
- Make 2 termials, for each termial make sure you are in your virtual env and have the requirments installed (if not look at the section in the README that tells you how to do this)
- On one termial cd into backend
- In the backend termial run
uvicorn main:app --reload
- On the other termial cd into frontend
- Run
npm start
- You will see messages in the backend terminal that the react app is connected
- Make sure you are in your virtual env and have the requirments installed (if not look at the section in the README that tells you how to do this)
- Cd into frontend
- Run
npm test