GeoIP2-python icon indicating copy to clipboard operation
GeoIP2-python copied to clipboard

File type error

Open dmittal200 opened this issue 10 months ago • 3 comments

geoip2.database.Reader()

This function accepts IO data type as it is mentioned in it's constructor but when I'm passing GeoLite-Country.mmdb file it is giving error like below :

ERROR:root:Failed to initialize GeoIP reader: expected str, bytes or os.PathLike object, not BytesIO

dmittal200 avatar Feb 19 '25 09:02 dmittal200

Are you using MODE_FD as directed in the constructor docs?

oschwald avatar Feb 19 '25 15:02 oschwald

Are you using MODE_FD as directed in the constructor docs?

I'm not using any mode it will be by default, do I need to pass specific type?

Also is mounting necessary to read file from GCS.

dmittal200 avatar Feb 20 '25 12:02 dmittal200

I may be misunderstanding what you are trying to do. MODE_FD is required when you are passing a file object to the reader. This is what the IO typing on the constructor argument is for. It sounds like you may be trying to pass some other IO type, which would likely not work currently.

oschwald avatar Feb 20 '25 15:02 oschwald