Failure to run basic_test_all.py

Not a lot of experience in this area for initial context. The code was missing for the GoPiGo project, so used github to clone it. In executing the python script basic_test_all.py, I am getting failures. The first attempt uses the standard “python” to run and it seems to not be able to find the smbus. I later found the smbus in a python3.2 library, so I ran it another time using python3.2 in the command; in this case it seems to get past the smbus issue, but now appears to fail on the print command in the script.

pi@raspberrypi ~/GoPiGo/Software/Python $ sudo python basic_test_all.py
Traceback (most recent call last):
File “basic_test_all.py”, line 2, in <module>
from gopigo import *
File “/home/pi/GoPiGo/Software/Python/gopigo.py”, line 30, in <module>
bus = smbus.SMBus(1)
IOError: [Errno 2] No such file or directory

pi@raspberrypi ~/GoPiGo/Software/Python $ sudo python3.2 basic_test_all.py
File “basic_test_all.py”, line 9
print “nCmd:”,
^
SyntaxError: invalid syntax


Extended file syntax:

while True:
print “nCmd:”,
a=raw_input()
if a==‘w’:
fwd()

Hey Scott,

Sorry to hear about this issue. The GoPiGo is written in Python 2.7. There migth be some syntax issues if you’re forcing 3.3

Did you run the setup script for the GoPiGo? (https://github.com/DexterInd/GoPiGo/tree/master/Setup)

Also, can you tell us more about the version of the Pi, the image you’re using (Dexter Industries Raspbian for Robots or other?)?

John

Raspberry Pi is a Model B+ shipped by CanaKit (purchased via Amazon). The online documentation shows that there was supposed to be an update process on the desktop which was missing, so I have been trying to manually install. I ended up going to github and running a clone.

I attempted the Setup,but it also fails. It appears to be syntactically incorrect. I am assuming it is a out of synch (script and libraries). This part of the code does not seem important and the network connection is working just fine. I don’t appear to have the ability to comment it out as the file permissions are preventing the same for some reason (can’t figure out how to override).

root@raspberrypi:/home/pi/GoPiGo/Setup# sudo sh install.sh


| __ | |
| | | | _____ | | ___ _ __
| | | |/ _ / / / _ '|
| || | /> <| || / |
|
/ __//
|| _ _
|
| | | | | ()
| | _ __ _| | _ | | _ __ _ ___ ___
| | | ’
/ ` | | | / __| | '| |/ _ / __|
| || | | | (
| | |
| __ |
| | | | /
|
|| ||,|_,|/|| ||__||___/

Welcome to GoPiGo Installer.
Please ensure internet connectivity before running this script.

NOTE: Raspberry Pi wil reboot after completion.Special thanks to Joe Sanford at Tufts University. This script was derived from his work. Thank you Joe! Must be running as Root user

Press ENTER to begin…
install.sh: 23: read: arg count

Check for internet connectivity…

install.sh: 29: install.sh: [[: not found
Unable to Connect, try again !!!


Here is the code

echo "Must be running as Root user"
echo " "
echo "Press ENTER to begin…"
read

echo " "
echo "Check for internet connectivity…"
echo "=================================="
wget -q --tries=2 --timeout=20 http://google.com
if [[ $? -eq 0 ]];then
echo "Connected"
else
echo "Unable to Connect, try again !!!"
exit 0
fi

echo " "
echo “Installing Dependencies”

After successfully commenting out the the ping test in the install.sh script, the install.sh ran successfully…

Including this bit from the output in case it is meaningful to the identity of the model.

Setting up Raspberry Pi to make it work with the Gertboard
and the ATmega chip on-board with the Arduino IDE.

Now for reboot and retest of the python script.

After reboot and script rerun, I am back to the same issues with the python script and the failure to run the smbus.

pi@raspberrypi ~/GoPiGo/Software/Python python -V Python 2.7.3 pi@raspberrypi ~/GoPiGo/Software/Python python basic_test_all.py
Traceback (most recent call last):
File “basic_test_all.py”, line 2, in <module>
from gopigo import *
File “/home/pi/GoPiGo/Software/Python/gopigo.py”, line 30, in <module>
bus = smbus.SMBus(1)
IOError: [Errno 2] No such file or directory

I removed and then updated python-smbus. Not sure if the fact that it refers to 3.1. in this update is an issue. (still fails)

root@raspberrypi:/home/pi/GoPiGo/Software/Python# apt-get install python-smbus
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following NEW packages will be installed:
python-smbus
0 upgraded, 1 newly installed, 0 to remove and 33 not upgraded.
Need to get 0 B/11.5 kB of archives.
After this operation, 94.2 kB of additional disk space will be used.
Selecting previously unselected package python-smbus.
(Reading database … 77756 files and directories currently installed.)
Unpacking python-smbus (from …/python-smbus_3.1.0-2_armhf.deb) …
Setting up python-smbus (3.1.0-2) …
root@raspberrypi:/home/pi/GoPiGo/Software/Python# python basic_test_all.py
Traceback (most recent call last):
File “basic_test_all.py”, line 2, in <module>
from gopigo import *
File “/home/pi/GoPiGo/Software/Python/gopigo.py”, line 30, in <module>
bus = smbus.SMBus(1)
IOError: [Errno 2] No such file or directory

Hey Scott,
Been trying to plug away at this, as well, I’m sorry for the delay. Just wanted you to know I’m working on it.

I was working on the Raspberry Pi 2 modifications and needed to make a few changes to get the smbus running in python. In particular, I did the following:

Add “dtparam=i2c_arm=on” to your config.txt and reboot.

Ran --> sudo raspi-config --> Advanced Options --> A7 I2C --> Yes.

When I ran Ran sudo i2cdetect -y 1
I saw a response.

If you make the change to config.txt and raspi-config, do you see any improvement?

John

I made this change and it now works!!!
Thank you!!!

Great! This is fantastic news. Just one quick question then: before you ran this, did you run a kernel update on the Pi? I’m just trying to make sure I understand what happened.

I’m still grateful the problem was solved though! We need to make sure we can help others when they have this problem.

No, I didn’t. But there still was some mystery. This is hard to explain, but here it goes.
I made the raspi-config change and rebooted. I am sure I tested after the reboot and was about to tell you it failed. In another forum thread on raspberrypi.org, I was given text to manually put in the /root/config.txt which was then followed up by someone saying that the raspi-config command would do that for me. I played with this to confirm, but I also saw the spi setting in raspi-config which I saw was failing at boot, so I played with toggling this on and off. After rebooting and testing, I was surprised when my test suddenly worked (totally expectantly). I attempted to nail down exactly what made it work, but was not able to. But I can tell you that the only actions I took was to update the /root/config.txt, the raspi-config and rebooted several times.

I hope that might trigger some thoughts, but again it wasn’t without some mystery. I am just so happy to get it to work. My boys are intrigued and already beginning to modify how they interact with it.