2013-03-01 3 views
0

adafruit가 raspberry 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" 

==============

"gps.py"파일의 맨 위에 "#!/usr/bin/python -tt"을 추가 한 다음 "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 

==============

답변

5

는 gps.py. 이외의 다른 스크립트의 이름을 변경하십시오 파이썬 인터프리터는 어딘가에 시스템 라이브러리에있는 gps.py 스크립트를 가져 오려고합니다.

관련 문제