mitsuhiko / python-geoip

GeoIP database access for Python under a BSD license.
Other
250 stars 52 forks source link

TypeError: 'str' does not support the buffer interface (py3 compat issue?) #2

Open bsdlp opened 10 years ago

bsdlp commented 10 years ago
(env)jchen@hobbes-(master|✔)> pip3.3 freeze -l
Flask==0.10.1
Flask-Script==0.6.7
Jinja2==2.7.2
MarkupSafe==0.18
Werkzeug==0.9.4
itsdangerous==0.23
python-geoip==1.2
python-geoip-geolite2==2014.0207
(env)jchen@hobbes-(master|✔)> python3
Python 3.3.4 (default, Feb 15 2014, 11:45:50)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from geoip import geolite2
>>> match = geolite2.lookup('66.228.43.47')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jchen/git/mirror_selector/env/lib/python3.3/site-packages/geoip.py", line 364, in lookup
    return self._get_actual_db().lookup(ip_addr)
  File "/Users/jchen/git/mirror_selector/env/lib/python3.3/site-packages/geoip.py", line 350, in _get_actual_db
    rv = self._load_database()
  File "/Users/jchen/git/mirror_selector/env/lib/python3.3/site-packages/geoip.py", line 342, in _load_database
    return mod.loader(self, sys.modules[__name__])
  File "/Users/jchen/git/mirror_selector/env/lib/python3.3/site-packages/_geoip_geolite2/__init__.py", line 9, in loader
    return mod.open_database(filename)
  File "/Users/jchen/git/mirror_selector/env/lib/python3.3/site-packages/geoip.py", line 508, in open_database
    md = _read_mmdb_metadata(buf)
  File "/Users/jchen/git/mirror_selector/env/lib/python3.3/site-packages/geoip.py", line 382, in _read_mmdb_metadata
    buf.size() - MMDB_METADATA_BLOCK_MAX_SIZE)
TypeError: 'str' does not support the buffer interface
emilgpa commented 10 years ago

Here same problem.

nephics commented 10 years ago

+1 for Python 3 support

annndrey commented 9 years ago

Same problem here.

busla commented 9 years ago

Yeah, same here.

bogdal commented 9 years ago

maxminddb-geolite2 is a good alternative and it supports python3.

busla commented 9 years ago

Thanks mate, works perfectly.

crclayton commented 8 years ago

Same problem. Neither src_ip.encode("utf-8") or bytes(src_ip, "utf-8") help.

yanagiragi commented 7 years ago

Platform : Window7 64 bit Same Problem. bytearray(src_ip, "utf-8") doesn;t help

However it works fine on Ubuntu

email365 commented 6 years ago

still experiencing the same error, any update or solution?

fl0wjacky commented 6 years ago

+1 for Python 3 support

datng2 commented 4 years ago

For those who came across this issue, please consider using GeoIP2 https://github.com/maxmind/GeoIP2-python

arshbot commented 4 years ago

@datng2 is it a direct stand in replacement?

datng2 commented 4 years ago

@arshbot I would recommend taking a look MaxMind DB reader as well. I think it also supports Enterprise version if you need to upgrade later.

https://github.com/maxmind/MaxMind-DB-Reader-python