somewhereinusa
Posts: 10
Joined: Thu Dec 10, 2015 1:59 pm
Location: Andrews,IN
Contact: Website

gps code Typeerror

Wed Jan 06, 2016 5:05 pm

I have a Raspberry Pi 2 with the latest Jessie.
When I try to run this code

Code: Select all

import gps
 
# Listen on port 2947 (gpsd) of localhost
session = gps.gps("localhost", "2947")
session.stream(gps.WATCH_ENABLE | gps.WATCH_NEWSTYLE)
 
while True:
    try:
    	report = session.next()
		# Wait for a 'TPV' report and display the current time
		# To see all report data, uncomment the line below
		# print report
        if report['class'] == 'TPV':
            if hasattr(report, 'time'):
                print report.time
    except KeyError:
		pass
    except KeyboardInterrupt:
		quit()
    except StopIteration:
		session = None
		print "GPSD has terminated"
from adafruit on this page https://learn.adafruit.com/adafruit-ult ... g-your-gps

I get this error message.
Traceback (most recent call last):
File "/home/pi/test.py", line 2, in <module>
import gps
File "/home/pi/gps.py", line 4, in <module>
session = gps.gps("localhost", "2947")
TypeError: 'module' object is not callable
I get the same message when trying to run other tutorial codes.

DirkS
Posts: 10371
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: gps code Typeerror

Wed Jan 06, 2016 5:11 pm

You have a file named 'gps.py' in your home directory. Python will try to use this one instead of the python-gps module.

Rename or remove that file and try again.

somewhereinusa
Posts: 10
Joined: Thu Dec 10, 2015 1:59 pm
Location: Andrews,IN
Contact: Website

Re: gps code Typeerror

Wed Jan 06, 2016 8:02 pm

Thanks, that did the trick. I had seen reference to that, thought it meant the name of this, not any file.

Return to “Beginners”