Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

PYTHONPATH

The ADC Pi is an Analogue to Digital converter for the Raspberry Pi

05/04/2016

Posted by:
Texy

Texy Avatar

Hi,I have been using the ADCPiPlus board for a while, but couldn't get the PYTHONPATH environmental to work so I just copied the relevant files to the same directory as the python script. I have just moved from Wheezy to Jessie on a raspberry pi 2 and rebuilding the OS for this project, but still have the same issue. The Libraries and PYTHONPATH are set to /home/pi/ABElectronics_Python_Libraries/ADCPi/ but it still replies with the error that it can't find the relevant files. Is the envirnomental PYTHONPATH supported?Also can you confirm that PYTHONPATH is cleared upon a reboot, as it appears to be.Thanks,Texy

05/04/2016

Posted by:
JonWeston

JonWeston Avatar

I'm having this issue too on Pi 3

05/04/2016

Posted by:
andrew

andrew Avatar

PYTHONPATH should work on the Raspberry Pi. I have just tried setting up a path to the ADCPi library folder on my Raspberry Pi 2 with the latest Jessi image and I could run the demo-readvoltage.py after moving it to the /home/pi/ folder.

PYTHONPATH is cleared on reboot but you can get around this by adding the path into the ~/.bashrc file which is parsed on boot. Open the .bashrc file using nano with the following command.

sudo nano ~/.bashrc

Move to the end of the file and add the following lines:

PATH="${PATH}:/home/pi/ABElectronics_Python_Libraries/ADCPi"
export PATH


PYTHONPATH="${PYTHONPATH}:/home/pi/ABElectronics_Python_Libraries/ADCPi"
export PYTHONPATH


Hopefully, after you reboot the path will be visible to python so you will be able to run scripts which use the ADCPi library from anywhere in the file system.

I haven't tried this on the Raspberry Pi 3 as my development system is on a Raspberry Pi 2 but as they are both running the same version of Raspian Linux it should work fine. Just to make sure I will try setting up a new image on a Raspberry Pi 3 and check it works.

Sign in to post your reply


Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view.
Download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.

Home

Shop

Learn

Forum

FAQ

Contact

0 item

Your cart is empty

Please browse our shop to order from the wide range of Raspberry Pi boards and accessories.

Subtotal:£0.00
View Basket Continue to Checkout