root@raspberrypi:~# python
Python 2.7.3 (default, Jan 13 2013, 11:20:46)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gps import gps
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name gps
>>> exit ()
好像不行。 安装的 debian 软件包: gpsd, gpsd-clients, python-gps, libgps20, libgps-dev
最佳答案
我在 Ubuntu 机器上试过它,它工作得很好:
$ python
Python 2.7.3 (default, Sep 26 2012, 21:51:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gps import gps
>>>
首先确保以下文件存在(保存目录因不同而不同):
/usr/lib/pyshared/python2.7/gps/packet.so
/usr/lib/pyshared/python2.7/gps/clienthelpers.so
/usr/lib/python2.7/dist-packages/gps-3.6.egg-info
/usr/lib/python2.7/dist-packages/gps/misc.py
/usr/lib/python2.7/dist-packages/gps/client.py
/usr/lib/python2.7/dist-packages/gps/fake.py
/usr/lib/python2.7/dist-packages/gps/__init__.py
/usr/lib/python2.7/dist-packages/gps/gps.py
这可以通过运行来完成:
dpkg -L python-gps
还要确保在运行 python 的目录中没有 gps.py
,因为这可能会搞砸导入程序。
关于python - 如何使用/安装 gps python 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15329152/