Python3安裝geohash

來源:互聯網
上載者:User

標籤:get   圖片   重新命名   名稱   有一個   ast   wiki   erro   back   

Geohash是一個可以對地理位置資訊進行加密和解密的系統,https://en.wikipedia.org/wiki/Geohash

Python安裝geohash庫後,可調用decode()和encode()函數。按照一般的步驟進行安裝(pip install geohash),在確認安裝成功後,import Geohash 仍然報錯:ImportError: No module named ‘geohash’, 說找不到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 中的內容後,成功。

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

 

Python3安裝geohash

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.