Knowledge Base

The AB Electronics UK Knowledge Base provides support solutions, tutorials and troubleshooting guides.

Knowledge Base

Using Pythonpath with the Python Libraries

Adding the library path to startup
Created: 31/01/2016 | Last Updated: 17/02/2021

This page details how to add the PYTHONPATH and PATH variables on the Raspberry Pi OS image from to use with our Python libraries allowing you to use the libraries from your scripts from any directory on your Raspberry Pi.

Step 1: Download the Python library from Github and extract the library to the directory of your choice, i.e ABElectronics_Python_Libraries/ADCPi

Step 2: Use CD to change to the directory containing the library files.

cd ABElectronics_Python_Libraries/ADCPi

Step 3: Use the pwd command to obtain the full directory path.


This will return the full path to the directory: /home/pi/Desktop/ABElectronics_Python_Libraries/ADCPi

Step 3 a:  We now edit the .bashrc file to include the library folder in the PATH and PYTHONPATH variables

sudo nano ~/.bashrc

Step 4:  Add the following lines to the .bashrc file at the end, replace this demo path to the correct location on your computer.

export PATH



Save your changes and exit the Nano editor.

Step 5: Reboot to apply the changes

sudo reboot

When your Raspberry Pi has rebooted you will now have PYTHONPATH to the library setup for Python 2 or 3 support.

Was this article helpful? Yes / No