0
我正在嘗試實施一個示例腳本,adafruit爲他們設計的覆盆子pi的gps單元之一提供。代碼如下:樹莓派上的GPS守護進程
==============
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"
==============
所以我將「#!/ usr/bin/python -tt」添加到「gps.py」文件的頂部,然後「chmod u + x /home/pi/gps.py」
運行此操作時,我收到以下錯誤,但我不明白爲什麼:
==============
[email protected] ~ $ /home/pi/gps.py
Traceback (most recent call last):
File "/home/pi/gps.py", line 2, in <module>
import gps
File "/home/pi/gps.py", line 5, in <module>
session = gps.gps("localhost", "2947")
TypeError: 'module' object is not callable
==============