Geohash是一个可以对地理位置信息进行加密和解密的系统,https://en.wikipedia.org/wiki/Geohash

Python安装geohash库后,可调用decode()和encode()函数。按照一般的步骤进行安装(pip install geohash),在确认安装成功后,import Geohash 仍然报错:ImportError: No module named ‘geohash’, 说找不到Geohash模块。

Python3安装geohash

百思不得其解。后面想到可能是Python3和Python2有所不一样,我用的是Python3。在网上找到一个解决方案:

rename the package name to be geohash rather than Geohash and then change init.py to import from .geohash (with a dot in front of the module name) rather than from geohash, the package should work for Python 3.5.2.

 

  解决办法是去python37/Lib/site-packages/目录下,把Geohash文件夹重命名为geohash【大写Geohash转为小写geohsah】,

     然后修改该目录下的__init__.py文件,把from geohash改为from .geohash【前面有一个dot】

 

按照这个方法修改文件名称和 init.py 中的内容后,成功。

Python3安装geohash

>>> import geohash
>>> geohash.encode(39.11111,12.22455,18)
'sqbwqpvwsxm4uf8tdy'
>>>

 

相关文章:

  • 2021-09-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-22
  • 2022-01-23
  • 2021-11-28
  • 2021-06-04
  • 2022-03-07
相关资源
相似解决方案