Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

Pi 3 and PYTHONPATH

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

13/05/2016

Posted by:
squiregeek

squiregeek Avatar

I've installed the ADC board and can run the readvoltage example script under python3. But when I try to run a script of my own, it chokes on from ABE_ADCPi import ADCPi, complaining no such file or directory. Using the file name in the home/pi folder I've added the following lines to /.bashrc:PATH="${PATH}:home/pi/ABElectronics_python3_libraries/ADCPi"export PATHPYTHONPATH="${PYTHONPATH}:home/pi/ABElectronics_python3_libraries/ADCPi"export PYTHONPATHls $PATH and ls $PYTHONPATH both retrun the error: no such file or directory.What am I missing?Thanks for your help.

13/05/2016

Posted by:
andrew

andrew Avatar

Try changing the path to be /home/pi/ABElectronics_Python3_Libraries/ADCPi

Linux is case sensitive so ABElectronics_python3_libraries with a lowercase P and L would be seen as a different directory.

13/05/2016

Posted by:
squiregeek

squiregeek Avatar

Thanks, Andrew. The directory added at install is ABElectronics_python3_libraries. Is PATH able to locate ABElectronics_Python3_Libraries?

13/05/2016

Posted by:
squiregeek

squiregeek Avatar

Andrew,I went back through the process and founD the git clone you referred to. I put the ABElectronics_Python3_Libraries in $PYTHONPATH in .bashrc and still no joy. I'll try a few variations and see if something will work. Progress... Jim

13/05/2016

Posted by:
andrew

andrew Avatar

Python 3 should work with PATH. I just tried setting up a path to the python 3 ADCPi library following our Python Path tutorial and after rebooting and copying the read voltage demo to the root directory I could run the demo and read from the ADC Pi.

13/05/2016

Posted by:
squiregeek

squiregeek Avatar

Andrew, this may be a clue to what I'm doing wrong. I changed the .bashrc entry to PATH="${PATH}:/home/pi/" and ls PATH still showed no file or directory. I'm clearling missing something here. No matter what directory I put in PATH or PYTHONPATH, it shows up when I run ls, but it's not recognized. I'm sure it's something simple, but I just can't see it.

13/05/2016

Posted by:
squiregeek

squiregeek Avatar

Here's what I get after entering ls:ls: cannot access :/home/pi/: no such file or directory.My entry in bashrc is PATH="${PATH}:/home/pi/"PATH cannot find my home directory. Clearly I've entered something wrong.

14/05/2016

Posted by:
andrew

andrew Avatar

Can you try running echo $PATH and see if that returns anything? On my raspberry pi it is returning

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/home/pi/Desktop/ABElectronics_Python3_Libraries/ADCPi

while ls PATH does return

ls: cannot access PATH: No such file or directory

If you try ls /home/pi/ABElectronics_python3_libraries/ADCPi does that go to the correct directory?

Also, are you editing the .bashrc file in your home directory or in the root? In the first post you mentioned /.bashrc . It should be the file in your home directory ~/.bashrc that you need to edit which you can get to with

sudo nano ~/.bashrc

14/05/2016

Posted by:
squiregeek

squiregeek Avatar

Andrew,I ran 'echo $PATH' and it returned the complete path without errors. 'echo $PYTHONPATH' also worked. I still was unable to run /home/pi/demo-readvoltage.py from the terminal but could from IDLE. I've been using 'sudo python3 demo-readvoltage.py' because an earlier version of the script used GPIO under Wheezy (no longer needed under Jessie). When I dropped the 'sudo' both the demo program from examples and my test script worked.I suspect that improper use of 'sudo' was the root of my problem. Perhaps it was referencing root's bashrc. Using 'ls $PATH' (as suggested on a couple of forums) instead of 'echo $PATH' led me astray. I am deeply grateful for your help. My project is back on track thanks your patient help.

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