python no module named serial

Viewed 42819

I am having a problem with my python program. I wrote the program to get the data(temperature) from arduino to my raspberry pi sqlite database. but it gives me an error at line4(import serial) saying "ImportError: No module named serial". I use python3 and have already updated the pyserial. i am new in python so i am making some mistakes...

 #!/ussr/bin/python
 # -*- coding: utf-8 -*-

 import serial
 import datetime
 import sqlite3 as lite
 import sys
 import time

 ser = serial.Serial('/dev/ttyACM1', 9600, timeout=1)
 ser.open()

 count = 0

 con = lite.connect('realtime_data.db')

 try:
       while 1:
         indata = ser.readline()
         current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
         count = count + 1

         print (count)

         with con:
           cur = con.cursor()
           cur.execute("INSERT INTO Temperatures VALUES( ?, ?, ? )", (count, current_time, indata))
           if count > 100:
             cur.execute("DELETE FROM Temperatures")
             count = 0

        # time.sleep(3) #upload to database every 5 seconds

 except KeyboardInterrupt:
       ser.close()
2 Answers
Related