...
If you haven’t already, download and install Python 3.8: https://www.python.org/
If you already have Python 3.7 or below installed, you must install Python 3.8 (you do not need to uninstall the other version(s)). This is because of a package dependency which requires Python 3.8 or greater.
Python 3.8.10 or later is recommended, otherwise you will have
pip
issues.
If you have Python 3.9 or above installed, you’re probably fine. Probably. Autonomy code is designed and tested on Python 3.8 so use a different version at your own risk.
Open the console in the repository root.
Windows: Use command prompt or PowerShell, not Git bash (the console that gets installed with Git).
Example:
C:\Users\Username\autonomy-bootcamp-2023
Create a virtual environment called
venv
by running:[python] -m venv venv/
, where[python]
is Python 3.8 (e.g.python
,python38
).You can check which version of Python it is by running
[python] --version
If you move the repository to a different path after creating a virtual environment, you will have to delete the
venv
directory and repeat this step. Additionally, if your virtual environment breaks for any reason, you can always delete thevenv
directory and repeat this step for a fresh environment.If you want to call the virtual environment by a different name, replace
venv/
with the name you want. Virtual environments are identified by their path, so different projects with the samevenv
virtual environment name is fine.Example:
C:\Users\Username\autonomy-bootcamp-2023\venv\
andC:\Users\Username\computer-vision-python\venv\
are different.
Activate the virtual environment:
Windows command prompt:
venv\Scripts\activate.bat
Windows Powershell:
.\venv\Scripts\Activate.ps1
If you get an error with:
running scripts is disabled on this system
Run:
Set-ExecutionPolicy Unrestricted
This allows you to run any Powershell scripts at will. For more detail: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.3
Linux and MacOS:
source venv/bin/activate
You should now see
(venv)
in the prompt line.Confirm the virtual environment uses Python 3.8:
python --version
Literally use
python
, none of the fancy stuff above.Example output:
Python 3.8.10
Open
requirements.txt
MacOS: Remove
+cu117
from bothtorch
andtorchvision
Windows and Linux:
If you have a CUDA capable GPU but don’t want to use it for some reason, change
+cu117
to+cpu
for bothtorch
andtorchvision
If you don’t have a CUDA capable GPU, don’t change anything.
Download and install required packages:
pip install -r requirements.txt
This will install in your virtual environment under
venv
. The rest of your system is unaffected.
Done!
...
If you haven’t already, activate the virtual environment:
Windows command prompt:
venv\Scripts\activate.bat
Windows Powershell:
.\venv\Scripts\Activate.ps1
Linux and MacOS:
source venv/bin/activate
You should now see
(venv)
in the prompt line.Code away! Run the tests! Please try to follow our style guide: Python Style Guide
Ask questions if you need help!
Make a commit:
Check which files have changed:
git status
Run:
git add [files you changed]
, where[files you changed]
are the files you want to add to the commit.Use
git add .
if you want to add all of them (the dot means wildcard in Git).
Run:
git commit -m "Your commit message"
When you’re ready to push your latest commits to GitHub:
git push
No harm in doing this after every commit.
When you’re done, make sure to either close the terminal or run:
Windows command prompt:
venv\Scripts\deactivate.bat
Everything else:
deactivate
This is important to avoid going to a different project and then accidentally polluting your current project’s virtual environment.
...