Environment set up
All the packages required to complete this tutorial are defined in here.
Copy this file into a file called dev_requirements.txt, and install with:
pip install -r dev_requirements.txt
I recommend you start this tutorial with a clean (empty) virtual environment but this is not technically required, as long as the required packages exist in your environment.
Linux terminal commands
# Create and activate new virtual environment
python3 -m venv new_venv # you may have to install e.g. sudo apt install python3.10-venv, follow the prompts
source new_venv/bin/activate # activate 'new_venv'
mkdir new_repo
cd new_repo
wget https://github.com/ACRF-Image-X-Institute/packaging_demo/raw/master/dev_requirements dev_requirements.txt
pip install -r dev_requirements
git init # set this folder up as a git repository. If you create a new repo on github, it will tell you the commands needed to push this repository
Windows Command Line and PowerShell
PyCharm usually manages environments in Windows quite well. However, if you would prefer to not use PyCharm, here are instructions for getting started with the Windows command line (cmd) or PowerShell. Generally, the commands below will work for both cmd and PowerShell, unless specified.
To open a command window anywhere from file explorer, just type cmd
in the address bar and press enter.
Create a new virtual environment (venv)
python -m venv new_venv
If this raises an error, try typing just
python
into the prompt. If you get a similar error (...python is not recognized as...
), then it is likely thepython.exe
cannot be found. See the below section on troubleshooting for help.Activate the venv by typing the full path to the activate script
new_venv\Scripts\activate
make a new directory for your new repo:
mkdir new_repo cd new_repo
Download the requirements file:
cmd:
curl -L https://github.com/ACRF-Image-X-Institute/packaging_demo/raw/master/dev_requirements --output dev_requirements.txt
PowerShell:
Invoke-WebRequest -URI https://github.com/ACRF-Image-X-Institute/packaging_demo/raw/master/dev_requirements -OutFile dev_requirements.txt
Install requirements through
pip
pip install -r dev_requirements.txt
Initialise the git repository
git init
At this point, you will have a terminal set up that you can complete the rest of this tutorial with.
Troubleshooting Windows Issues
Can’t find
python.exe
When python can’t be found, it is usually because location of
python.exe
is not on thePATH
. There are a few ways to fix this, and best practice depends on how you installed python:Anaconda/conda
Anaconda comes with the Anaconda Prompt, which you can use instead of cmd. This will have python set up correctly.
Alternatively, you can use conda environments:
conda create -n python3 python conda activate python3
From the Python website
If you have yet to install python, you can let the installer add the location of the python executable to
PATH
.Select “Add Python to PATH” when installing:
If Python is already installed, see the next part about adding python to
PATH
Adding Python to
PATH
Finally, regardless of how python is installed, you can always add it to
PATH
. This will make it available in cmd or PowerShell. This is a bit tricky as you need to find out where Python is installed. Common locations are:C:\Users\<username>\AppData\Local\Programs\
C:\Users\<username>\AppData\Local\
C:\Program Files\
C:\Program Files (x86)\
You will have to dig around in these locations for folders that may contain the python installation. You are looking for the full path to the folder containing
python.exe
. For example, ifpython.exe
is located atC:\path\to\python.exe
, you wantC:\path\to\
. Once you have foundpython.exe
, you need to find the location ofpip.exe
. This may be in the same folder aspython.exe
, or in a subdirectory calledScripts
. If not, you will need to search around. You need both the path to the python folder and to the pip folder.Once you have the path, you add to
PATH
by:Search for “Edit the system environment variables” in the start menu, and open the top result
Click on “Environment Variables…”
Under “User variables for
”, select the variable named “Path” and click “Edit” In the new window, click “New”, then copy the python path you found into the field
Click “New” again, and copy the pip path into the field
Exit out of all menus by clicking “OK”
Python and pip should be available when a new PowerShell or cmd prompt is opened.