По пытался так:
import pygeoip gi = pygeoip.GeoIP('GeoLiteCity.dat') print(gi.region_by_addr('14.139.61.12'))
но ароучил ответ
FileNotFoundError: No such file or directory: ‘GeoLiteCity.dat’
А как надо? может какой другой модуль подключить?
import pygeoip gi = pygeoip.GeoIP('GeoLiteCity.dat') print(gi.region_by_addr('14.139.61.12'))
FileNotFoundError: No such file or directory: ‘GeoLiteCity.dat’
class pygeoip.GeoIP(filename, flags=0, cache=True) __init__(filename, flags=0, cache=True) '''Create and return an GeoIP instance. Parameters: filename – File path to a GeoIP database путь к файлу базы данных GeoIP flags – Flags that affect how the database is processed. Currently supported flags are STANDARD (default), MEMORY_CACHE (preload the whole file into memory) and MMAP_CACHE (access the file via mmap) cache – Used in tests to skip instance caching'''
AreostarВыполни
А как надо? может какой другой модуль подключить?
import os print(os.getcwd())
py.user.next
AreostarВот там ты и пытаешься найти файл, которого там нет.
узнать свое место положение я могу.
AreostarЭто не проблема pygeoip. Ты просто неправильно указал путь к файлу. Указывай полный путь к файлу с данными, либо положи файл с данными туда, откуда скрипт запускаешь. Как узнать, откуда ты запускаешь скрипт, я тебе показал сообщением выше. Если вывод скрипта не можешь читать, то запиши вывод в файл /tmp/file.txt и прочитай потом из файла /tmp/file.txt .FileNotFoundError: No such file or directory: 'GeoLiteCity.dat'