607011 / weatherbot

Weather report and forecast bot for Telegram
GNU General Public License v3.0
3 stars 0 forks source link

from pyowm.city import CityList #1

Open danst0 opened 7 years ago

danst0 commented 7 years ago

Hallo,

ich habe pyowm per pip3 installiert. from pyowm.city import CityList

führt zu ImportError: cannot import name 'CityList'

Daniel

607011 commented 7 years ago

Das Projekt weatherbot verwendet nicht das per pip3 installierbare pyowm, sondern ein eigenes Modul mit gleichem Namen. Vielleicht sollte ich das mal in pyowm-micro umbenennen; so heißt schließlich auch das Repository.

danst0 commented 7 years ago

Ok. Installiert. Jetzt fehlte mir noch ein Beispiel für die config json. Insbesondere "openweathermap": {"api_key": "xxxxxx", ???}

607011 commented 7 years ago

config.json-Beispiel:

{
  "telegram_bot_token": "...",
  "timeout_secs": 3600,
  "authorized_users": [ 123456787, 123456789 ],
  "openweathermap": {
    "city_list": "./pyowm/city.list.reduced.json.bz2",
    "api_key": "0123456789abcdef..."
  },
  "verbose": true
}

authorized_users: Liste der Telegram-IDs, die den Bot nutzen dürfen telegram_bot_token: Telegram API Key openweathermap/api_key: OWM API Key

danst0 commented 7 years ago

Danke für die schnelle Hilfe. Ich habe die city.lists aus dem pyowm-micro jetzt in das pyowm-Verzeichnis des Bots kopiert. Das Entpacken scheint noch nicht zu funktionieren...

pi@kirby ~/weatherbot ❯❯❯ ls pyowm city.de.list.reduced.json.bz2 city.list.reduced.json.bz2

pi@kirby ~/weatherbot ❯❯❯ ./weatherbot.py Traceback (most recent call last): File "./weatherbot.py", line 350, in <module> main() File "./weatherbot.py", line 329, in main lambda p: print('\rLoading city list ... {:d}%'.format(p), end='', flush=True)) File "/usr/local/lib/python3.4/dist-packages/pyowm_micro-1.0.3-py3.4.egg/pyowm/city.py", line 119, in read File "/usr/lib/python3.4/bz2.py", line 365, in readlines return io.BufferedIOBase.readlines(self, size) File "/usr/lib/python3.4/bz2.py", line 351, in readline return io.BufferedIOBase.readline(self, size) File "/usr/lib/python3.4/bz2.py", line 276, in peek if not self._fill_buffer(): File "/usr/lib/python3.4/bz2.py", line 218, in _fill_buffer self._buffer = self._decompressor.decompress(rawblock) OSError: Invalid data stream