BrickPi_Python icon indicating copy to clipboard operation
BrickPi_Python copied to clipboard

Error running EV3-Touch.py "ImportError: No module named builtins"

Open fantauzzi opened this issue 9 years ago • 8 comments

cd to directory BrickPi_Python/Sensor_Examples and run

} sudo python EV3-Touch.py
Traceback (most recent call last):
  File "EV3-Touch.py", line 24, in <module>
    from BrickPi import *   							#import BrickPi.py file to use BrickPi operations
  File "/home/pi/workspace/BrickPi_Python-master/Sensor_Examples/BrickPi.py", line 47, in <module>
    from builtins import input
ImportError: No module named builtins

Output of uname -a is

} uname -a
Linux dex 4.4.32-v7+ #924 SMP Tue Nov 15 18:11:28 GMT 2016 armv7l GNU/Linux

fantauzzi avatar Nov 25 '16 09:11 fantauzzi

Hi. You need to run sudo pip install -U future in a terminal to add the library in question. It's added already for our Raspbian for Robots so I'm assuming you're running your own OS.

CleoQc avatar Nov 25 '16 12:11 CleoQc

Hi! I am running the Raspbian for Robots downloaded from here: https://drive.google.com/file/d/0B0WChwP4CnLBV2R6VE8yeFF2ZFU/view?usp=sharing as per instructions reported here: https://www.dexterindustries.com/howto/install-raspbian-for-robots-image-on-an-sd-card/ I have just re-imaged the micro SD with it, it is a fresh install. Here the output of uname -a

Linux dex 4.4.32-v7+ #924 SMP Tue Nov 15 18:11:28 GMT 2016 armv7l GNU/Linux

Should I use a different image instead?

fantauzzi avatar Nov 25 '16 16:11 fantauzzi

You're doing every thing right. The issue is that this is a recent change. Our apologies. Did you pull down the repo directly from Github? In short, you seem to be out of sync. If you go through DI Update, you would be getting the latest BrickPi code and the library import that is now required. Or you can just enter sudo pip install -U future
in a command prompt to get the missing library.

CleoQc avatar Nov 25 '16 16:11 CleoQc

And thank you for bringing this to our attention. There's now a PR that will take care of this for others . https://github.com/DexterInd/BrickPi_Python/pull/79

CleoQc avatar Nov 25 '16 16:11 CleoQc

I downloaded the repo from github as a zip file. sudo pip install -U future resolved the issue. Thanks!

fantauzzi avatar Nov 25 '16 17:11 fantauzzi

Great!!! Just to be safe, you also need to run python setup.py install if you haven't already done so.

CleoQc avatar Nov 25 '16 17:11 CleoQc

In the output of pip I see BrickPy is already installed. Do I need to run python setup.py install nevertheless?

} pip list | grep BrickPi
BrickPi (0.0.0)

fantauzzi avatar Nov 25 '16 17:11 fantauzzi

Since your base is Raspbian for Robots, and it's the latest version, you're most likely set and don't need to run it. Apologies again for this hiccup you faced.

CleoQc avatar Nov 25 '16 17:11 CleoQc