Geohash是一个可以对地理位置信息进行加密和解密的系统,https://en.wikipedia.org/wiki/Geohash
Python安装geohash库后,可调用decode()
和encode()
函数。
按照一般的步骤进行安装pip install geohash
,在确认安装成功后,import Geohash
仍然报错: ImportError: No module named ‘geohash’
, 说找不到Geohash模块。
如下错误:
Traceback (most recent call last):
xxx ...
xxx ...
File "/xxx/xxx/.../site-packages/Geohash/__init__.py", line 21, in <module>
from geohash import decode_exactly, decode, encode
ModuleNotFoundError: No module named 'geohash'
其实我们安装的是 Geohash 模块,该模块内部路径导入貌似有 bug,建议安装更快、更精确的 python-geohash 模块。
解决方法1(推荐)
pip3 install python-geohash
如果安装失败,在下面链接下载.whl
文件安装
https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-geohash
解决方法2
1、将Geohash文件夹改成geohash;
2、将文件夹下的 __init__.py
中的 from geohash
改成 from .geohash
(注意:在geohash前面多了一个点)
简单使用
# from geohash import decode_exactly, decode, encode
import geohash
# 原始数据提供的Geohash值是 wx4gfbe,把这个值解码成一个点的经纬度。
geohash.decode('wx4gfbe')
参考:https://my.oschina.net/u/3826227/blog/1818647
https://www.knowledgedict.com/tutorial/python-no-module-geohash-error.html
https://blog.csdn.net/Jinlong_Xu/article/details/73822759