9

I am using ipython Jupyter notebook in Windows 10. I have installed Geohash using pip install geohash in cmd. When I try to use geohash( import geohash) following error comes:

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

ImportError: No module named 'geohash'

Again check whether geohash installed or not then following message came while I try to reinstall:

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)

Again I uninstall geohash. I manually install geohash from github but same problem occur : import error

Thomas K
  • 39,200
  • 7
  • 84
  • 86
Himal Acharya
  • 836
  • 4
  • 14
  • 24

4 Answers4

28
pip install python-geohash

This should fix it.

Marco Bonelli
  • 63,369
  • 21
  • 118
  • 128
  • install --record /private/var/folders/wn/6f963chj009_0rqllwdyjjn00000gn/T/pip-record-s7c_fi9v/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/wn/6f963chj009_0rqllwdyjjn00000gn/T/pip-install-ptlms8nj/python-geohash/ – Fabian Bosler Jun 28 '19 at 12:12
  • 1
    it mix things, and make Geohash import python-geohash code. it become a nightmare to know which code is executed in your project. I just lost 2 days trying to understand why Geohash.decode were responding strings in a project and numbers in another one. So if you do that, please uninstall Geohash before ! – JR Utily Aug 02 '19 at 08:57
5

Found another way and it works like charm.

from gd-inm source: https://github.com/vinsci/geohash/issues/4

  1. rename the package name to be geohash rather than Geohash
  2. change init.py to import from .geohash (with a dot in front of the module name) rather than from geohash

I had the same issue - if you 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.

PoonLamy
  • 101
  • 1
  • 2
  • 4
3
pip uninstall Geohash
pip install geohash2

it will install https://github.com/DBarthe/geohash version which is exactly the same as vinsci one but compliant with Python 3 import syntax (DBarthe did what @PoonLany explained in its answer)

JR Utily
  • 1,792
  • 1
  • 23
  • 38
0

I had the same problem with python3 which makes me use "pygeohash" instead of geohash.

Instalation

pip install pygeohash

usage

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