Ipython 已安装Geohash模块,但导入错误

Ipython 已安装Geohash模块,但导入错误,ipython,geohashing,Ipython,Geohashing,我正在Windows 10中使用ipython Jupyter笔记本。我已经在cmd中使用pip install Geohash安装了Geohash。 当我尝试使用geohash(导入geohash)时,出现以下错误: --------------------------------------------------------------------------- ImportError Traceback (most recent

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

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

ImportError: No module named 'geohash'
我再次卸载geohash。我从github手动安装geohash,但出现了相同的问题: 导入错误

pip install python-geohash

这应该可以解决它。

找到了另一种方法,它就像魅力一样工作

来自gd inm来源:

  • 将包名称重命名为geohash而不是geohash
  • init.py更改为从.geohash导入(模块名称前面有一个点),而不是从geohash导入
  • 我也有同样的问题-如果您将包名重命名为geohash 而不是Geohash,然后将init.py更改为从导入 .geohash(模块名称前面有一个点),而不是来自 geohash,该包应该适用于Python 3.5.2


    它将安装与vinsci one完全相同的版本,但符合python3导入语法(DBarthe做了@PoonLany在其回答中解释的事情)

    我对python3也有同样的问题,它让我使用“”而不是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
    

    你能检查一下笔记本中的
    sys.path
    吗?我检查了站点包..它显示..但我不知道如何将该模块放在Windows中的sys.path中是sys.path中特定的
    site packages
    目录吗?笔记本可能正在另一个环境中运行,因此它会看到不同的site-packages.install--record/private/var/folders/wn/6f963chj009_0RQLLWDYJJN0000GN/T/pip-record-s7c_fi9v/install-record.txt--外部管理的单一版本--编译“在/private/var/folders/wn/6f963chj009\u 0RQLLWDYJJN0000GN/T/pip-install-ptlms8nj/python geohash/it mix things中出现错误代码1,并使geohash导入python geohash代码。”。知道在您的项目中执行哪些代码将成为一场噩梦。我花了两天时间试图理解为什么Geohash.decode在一个项目中响应字符串,在另一个项目中响应数字。因此,如果您这样做,请先卸载Geohash!现在有了geohash2,它可以很好地实现这一点,因此您不必接触代码
    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