9

我在 Windows 10 中使用 ipython Jupyter 笔记本。我在 cmd 中使用 pip install geohash 安装了 Geohash。当我尝试使用 geohash(import geohash) 时出现以下错误:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-7-840910eb012f> in <module>()
----> 1 import geohash

ImportError: No module named 'geohash'

再次检查 geohash 是否安装,然后在我尝试重新安装时出现以下消息:

C:\Users\Himal Acharya>pip install geohash
Requirement already satisfied (use --upgrade to upgrade): geohash in c:\users\himal acharya\anaconda3\lib\site-packages
Requirement already satisfied (use --upgrade to upgrade): docutils>=0.3 in c:\users\himal acharya\anaconda3\lib\site-packages (from geohash)

我再次卸载 geohash。我从 github 手动安装 geohash 但出现同样的问题:导入错误

4

4 回答 4

27
pip install python-geohash

这应该解决它。

于 2017-04-24T21:09:46.090 回答
5

找到了另一种方式,它就像魅力一样。

来自 gd-inm 来源:https ://github.com/vinsci/geohash/issues/4

  1. 将包名重命名为 geohash 而不是 Geohash
  2. init .py 更改为从 .geohash 导入(模块名称前有一个点)而不是从 geohash

我遇到了同样的问题 - 如果您将包名称重命名为 geohash 而不是 Geohash,然后将init .py 更改为从 .geohash(模块名称前有一个点)而不是从 geohash 导入,则该包应该适用于蟒蛇 3.5.2。

于 2019-06-03T07:17:15.543 回答
3
pip uninstall Geohash
pip install geohash2

它将安装https://github.com/DBarthe/geohash版本,该版本与 vinsci 版本完全相同,但符合 Python 3 导入语法(DBarthe 做了@PoonLany 在其答案中解释的操作)

于 2019-08-02T09:00:57.823 回答
0

我对 python3 有同样的问题,这让我使用“ pygeohash ”而不是 geohash。

安装

pip install pygeohash

用法

import pygeohash as pgh

pgh.encode(42.6, -5.6)
# >>> 'ezs42e44yx96'

pgh.encode(42.6, -5.6, precision=5)
# >>> 'ezs42'

pgh.decode('ezs42')
# >>> ('42.6', '-5.6')

pgh.geohash_approximate_distance('bcd3u', 'bc83n')
# >>> 625441
于 2019-09-22T07:39:05.087 回答