取り急ぎメモ.
環境
Windows, Cygwin, Python2.7
インストール
libGeoIP-develが必要.
管理者権限でCygwinを起動して以下を実行.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
$ apt-cyg install libGeoIP-devel ~~~ hash_check: sha512sum: GeoIP-database-20161207-1.tar.xz: OK Unpacking... Package GeoIP-database installed Package cygwin is already installed, skipping Package libGeoIP1 installed Package pkg-config is already installed, skipping Running postinstall scripts Package libGeoIP-devel installed $ pip install GeoIP Collecting GeoIP Using cached GeoIP-1.3.2.tar.gz Installing collected packages: GeoIP Running setup.py install for GeoIP ... done Successfully installed GeoIP-1.3.2 |
実行確認
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$ python Python 2.7.10 (default, Jun 1 2015, 18:17:45) [GCC 4.9.2] on cygwin Type "help", "copyright", "credits" or "license" for more information. >>> import GepIP Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named GepIP >>> import GeoIP >>> gi = GeoIP.new(GeoIP.GEOIP_MEMORY_CACHE) >>> gi.country_code_by_name("yahoo.com") 'US' >>> gi.country_code_by_addr("107.189.171.198") 'US' |