1. On your Raspberry Pi, create the folder that will host your project.
Open the terminal, navigate to the folder where your projects are stored, and create a new folder (I’ll call it “RaspController Notification Proj,” but you can name it whatever you like):
mkdir "RaspController Notification Proj"
2. Create your virtual environment
Go to your project folder:
cd "RaspController Notification Proj"
and choose a name for your environment (I’ll call it raspc_env, but you can name it whatever you like). This will create a new folder called “raspc_env.”
python3 -m venv raspc_env
3. Activate the virtual environment
source raspc_env/bin/activate
You’ll notice your terminal prompt change to show the environment name (e.g., (raspc_env)$). This means you’re in the virtual environment!
4. Update the standard Python package manager “pip” and install the raspc-notif library.
Note 1: You can now only use “python” instead of “python3” because we’re in a virtual environment.
python -m pip install --upgrade pip
python -m pip install --upgrade raspc-notif
Note 2: The "install --upgrade" parameters install the package if it isn’t present or upgrade it if it’s present.
Note 3: It’s recommended to keep the raspc-notif library up to date.
Note 4: You can find the library documentation here: raspc-notif documentation
5. Add your custom script
Create your Python scripts inside your “RaspController Notification Proj” project folder, following the example below.
6. Deactivate the virtual environment
When you’re finished working, simply type:
deactivate
The terminal prompt will return to normal.
Warning: Python virtual environments (the raspc_env folder) cannot be moved or renamed after they are created.
If the absolute path changes because the parent folders have been renamed or moved, you must delete the virtual environment with:
rm -rf raspc_env
and create a new, clean environment:
python3 -m venv raspc_env