1

I deploy my telegram bot on Heroku and I use pyTelegramBotapi and geopy. The last time I deploy, it was 10 days ago, all was working fine but today when I starting command /geo I found that goopy Nominatim broken my function when it is on Heroku, but if bot is working on my computer everything is working great. What's the matter?

def geo_continue(message):
    bot.send_message(message.chat.id,"We are here!")
    if message.location!=None:
        from geopy import Nominatim
        global locator
        locator = Nominatim(user_agent="myGeocoder")
        global users_latitude,users_longitude
        users_latitude = message.location.latitude
        users_longitude = message.location.longitude
        bot.send_message(message.chat.id,locator.reverse(f"{message.location.latitude}, {message.location.longitude}",language="ru"))#it is breaking here
        bot.send_message(message.chat.id,f"{users_longitude}, {users_latitude}")
        if locator.reverse(f"{message.location.latitude}, {message.location.longitude}",language="ru") is None:
            if users_language == 0:
                bot.send_message(message.chat.id, "Sorry, this function works only in Belarus, yet.")
            else:
                bot.send_message(message.chat.id, "Извините, эта функция работает пока только в Беларуси.")
            non_keyboard = types.ReplyKeyboardRemove(selective=False)
            bot.send_message(message.chat.id, "Ok.", reply_markup=non_keyboard)
        else:
            bot.send_message(message.chat.id, "Now we are here!")
            users_geo_data = locator.reverse(f"{message.location.latitude}, {message.location.longitude}",
                                             language="ru").raw
navajo
  • 11
  • 1
  • Can you share the error with us or anything like that? anyway, please edit your question to make it a little bit more clear. – Arsham Arya Apr 27 '22 at 21:53

1 Answers1

1

Check if you have included geopy in your requirements.txt file

  • 2
    Welcome to Stack Overflow! Please phrase this as an explained conditional answer, in order to avoid the impression of asking a clarification question instead of answering (for which a comment should be used instead of an answer, compare https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead ). For example like "If your problem is ... then the solution is to .... because .... ." – Yunnosch Apr 27 '22 at 17:57
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 28 '22 at 04:36