python - 如何使用/安装 gps python 库

标签 python python-2.7 gps

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/

相关文章:

python - jinja2 - 如何在 if 语句中放置一个 block ?

python - 爬虫返回空结果

android - 位置更改通知android

android - iOS/Android GPS 电量消耗?

python - 如何检查列表中是否只有指定的元素?

python - 厌倦了 ASP.NET,我应该学习以下哪些内容,为什么?

python - 在 Python 中从 XML 字符串/文件创建元组

python - Django - 如何覆盖每个语言环境的默认日期格式?

python-2.7 - 如何在 PyQt4 中更改 QTextEdit 中所有内容的字体大小?

javascript - 如何在 Node.js 中使用 GPS?