4
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

4

2 回答 2

3

我在 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

还要确保gps.py在您运行 python 的目录中没有放置任何东西,因为这可能会搞砸导入器。

于 2013-03-11T02:01:30.540 回答
1

It might be useful to add that even after removing gps.py, I had a file called gps.pyc which was also creating this problem. u remove this file and then problem vanishes..

于 2015-01-30T15:21:18.017 回答