pythonraspberry-pigpsd

Python GPSD Library Import Configuration


I'm working on a writing a Python script that will interface with and pull GPSD data into an application. This obviously involves an external library.

I have set up my configuration as follows on the Raspberry Pi I am using to deploy the code:

sudo apt-get install gpsd gpsd-clients python-gps

I have a working test sample code that creates the gps listener and pulls in data. It looks something like this:

gpsd = gps(mode=WATCH_ENABLE)
while gpsp.running:
    gpsd.next()

It works great if I run it by calling the following command:

python test.py

But the code breaks due to an ImportError:

Traceback (most recent call last):
  File "main.py", line 1, in <module>
    from gps import *
ImportError: No module named gps

If I run it using:

python3 test.py

This makes sense to me because when I set up the project, I only included the libraries for the default Python (Python 2.7), not Python 3. But python3-gps isn't a package, and the rest of my project demands Python 3, so I don't know what to do.

Would it be possible to copy the Python 2.7 build of the gps library into Python 3 without errors? What other libraries should I look at? Is there anyway around this error?

Thanks so much!


Solution

  • There actually is a version make for version 3 -- see GitHub here...

    https://github.com/tpoche/gps-python3

    It advertises itself as a simple port to python 3....