GrovePi Python3 not working


#1

Hello All,

I have just got my GrovePi and am running it on my RasberryPi B with your image. When I try to run the my py Script using Sudo Python3 I get this error <module> from grovepi import *

I tried looking across this forum and the search Google but thave not found a fix.

Is there a fix and will GrovePi work with Python3x?

Hope someone can help


#2

Hey,
GrovePi should work with Python3. Can you post the complete error that you are getting along with how you were trying to run the program.

-Karan


#3

Thankyou for replying.

I am a novice to programing and so that could be the reason. The script and error are as follows:

pi@dex12 ~/Desktop/My_Projects/Sensors $ sudo python3 multi3.py
Traceback (most recent call last):
File “multi3.py”, line 18, in <module>
from grovepi import *
ImportError: No module named grovepi

2 - DHT21 - black one, aka AM2301

For more info please see: http://www.dexterindustries.com/topic/537-6c-displayed-in-home-weather-project/

#!/usr/bin/python3

from grovepi import *
from grove_rgb_lcd import *
import datetime
import grovepi

dht_sensor_port = 7 # Connect the DHt sensor to port 7
dht_sensor_type = 0 # change this depending on your sensor type - see header comment

light_sensor = 0 # Connect the Grove Light Sensor to analog port A0 - SIG,NC,VCC,GND

led = 4 # Connect the Grove LED to digital port D4

while True:
try:
[ temp,hum ] = dht(dht_sensor_port,dht_sensor_type) #Get the temperature and Humidity from the DHT sensor

	# Get sensor values
	light = grovepi.analogRead(light_sensor)
	digitalWrite(led,1)	#Blink the LED

Config Sensor Values

	l = int(light)
	l1 = str(light)

	t = int(temp)
	t1 = str(temp)

	h = int(hum)
	h1 = str(hum)

Output

	print(t, h, l)
	setRGB(0,255,0)
	setRGB(200,125,140)
	setText("T:" + t1 + "   " + "H:" + h1 +" " + "L:" + l1)
	time.sleep(5)  # Delay for 5 seconds
	digitalWrite(led,0)
except (IOError,TypeError) as e:
	print ("Error")

#4

Hey,
Are you using your own image for the Raspberry Pi and not the Raspbian for Robots image. If you are, did you install the software and settings for the GrovePi from the link here: http://www.dexterindustries.com/GrovePi/get-started-with-the-grovepi/setting-software/.

-Karan


#5

Hi Karan,

I have been using the latest Raspbian for Robots images, and followed the instructions on your webpage you posted


#6

H Karan

Just check, is this the correct link http://www.dexterindustries.com/howto/install-raspbian-for-robots-image-on-an-sd-card/

If it is then its that Image I use


#7

Hey Whimickrh, here’s the link for downloading the image: https://drive.google.com/open?id=0B0WChwP4CnLBbE40YjZYMjV4QkE


#8

Thanks for the Link, I will download the image tonight and try on tuesday


#9

Thanks for the Link, I have just tried to run this Python3 script below, sudo python3 Led.py:

LED.py

from grovepi import *
import datetime

led = 4

while True:
try:

	digitalWrite(led,1)	#Blink the LED
	print("Led On")
	time.sleep(5)  # Delay for 5 seconds

	digitalWrite(led,0)
except (IOError,TypeError) as e:
	print ("Error")

Sadly it does not word and produced this error:

pi@dex ~/Desktop/My_Projects/Sensors $ sudo python3 Led.py
Traceback (most recent call last):
File “Led.py”, line 3, in <module>
from grovepi import *
ImportError: No module named grovepi

I also tried using import grovepi, and the same error was caused.

sudo python3 Led.py
Traceback (most recent call last):
File “Led.py”, line 3, in <module>
import grovepi
ImportError: No module named grovepi

Have you any suggestions how to solve this error?


#10

Temporary workaround might be to copy the file “grovepi.py” into the directory you’re working out of.


#11

Work around by copying grovepi.py, did not work, at least not for me.

Still can not import grovepi modules


#12

Hi
Should I give up trying to use Python3??


#13

“”" Work around by copying grovepi.py, did not work, at least not for me.

Still can not import grovepi modules “”"

You’re saying it didn’t work; did it throw an error message to you?


#14

Hi the problem is when I use sudo python3 Led3.py, it returns the same error
Traceback (most recent call last):
File “Led.py”, line 3, in <module>
import grovepi
ImportError: No module named grovepi

Even with grovepi.py copied to the same folder, causes the same error.

How do I get the GrovePi modules installed so they run with python3x.
I have searched the internet for a sollution, and they all point back to running something like setuptools, which I believe is used for installing the GrovePi modules so python3x can use them. I have scene in the python3 documentaion that setuptools is no longer used.
Could the installation script setup.py, be at fault?

I believe this problem has been reported sometime in an easrlier post, and may not have been fixed.