Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'Animation' from 'telegram' #9

Closed
hndrk-themer opened this issue Feb 17, 2022 · 6 comments
Closed

ImportError: cannot import name 'Animation' from 'telegram' #9

hndrk-themer opened this issue Feb 17, 2022 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@hndrk-themer
Copy link

After running your bot like for over 7months without problem i cant start it anymore. I literally changed nothing.

I reinstalled like stated in readme, i even did the poetry way after i couldnt get it fixed, but nothing.

On Python 3.8:

ImportError: cannot import name 'TelegramError' from 'telegram' (....

on Python 3.9:

ImportError: cannot import name 'Animation' from 'telegram' (...

@mkdryden
Copy link
Owner

Interesting, there may have been a change in python-telegram-bot or something, though if you used poetry, it should use the poetry.lock file to use the specific versions. When I get a chance I will take a peek and see if I can reproduce it, though if you could give me the full traceback and what OS you're using, that might be helpful. As a quick stop-gap to get you back up and running, you might want to try the Docker version. If you use the 0.6.3 tag from my repository, that version was definitely working and should not have had any packages updated.

@hndrk-themer
Copy link
Author

thanks! alright the bot is running again via docker ... i totally forgot that there is a docker image.

My Homeserver runs latest and fully updated Debian. As i said before i tested under Python 3.8 and Python 3.9.

Here is the complete Output:

Traceback (most recent call last):
File "/usr/local/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/hendrik/.local/lib/python3.8/site-packages/telegram_stats_bot/main.py", line 31, in
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackContext, JobQueue
File "/home/hendrik/.local/lib/python3.8/site-packages/telegram/ext/init.py", line 21, in
from .dispatcher import Dispatcher, DispatcherHandlerStop, run_async
File "/home/hendrik/.local/lib/python3.8/site-packages/telegram/ext/dispatcher.py", line 33, in
from telegram import TelegramError
ImportError: cannot import name 'TelegramError' from 'telegram' (/home/hendrik/.local/lib/python3.8/site-packages/telegram/init.py)

@mkdryden mkdryden self-assigned this Feb 17, 2022
@mkdryden mkdryden added the bug Something isn't working label Feb 17, 2022
@mkdryden
Copy link
Owner

mkdryden commented Feb 27, 2022

I have not been able to reproduce this on either Ubuntu or Windows with any Python version between 3.8 and 3.10, installing with either pip or Poetry, so I'm not sure what happened. Just in case, I have updated the python-telegram-bot requirement to the latest, in case some old version of it in your environment was causing the problem, and updated the poetry lock file to the latest compatible version of everything, in v0.6.4.

@TheLexoPlexx
Copy link

I stumbled upon this same error in Python 3.8 when I accidentally installed the python-telegram-bot alongside the telegram-package. Uninstalling both and reinstallong only the required one did the trick.

@mkdryden
Copy link
Owner

mkdryden commented Apr 7, 2022

I stumbled upon this same error in Python 3.8 when I accidentally installed the python-telegram-bot alongside the telegram-package. Uninstalling both and reinstallong only the required one did the trick.

Ah, this makes sense. The telegram package seems to be some other defunct project with packages still on pypi and they share the same import names. I don't think there is any reason to use this package for anything, but I guess if you do, then it should be isolated from telegram-stats-bot by using a different venv/conda environment/etc.

@ldhuy-proj
Copy link

I stumbled upon this same error in Python 3.8 when I accidentally installed the python-telegram-bot alongside the telegram-package. Uninstalling both and reinstallong only the required one did the trick.

This really solved the problem for me, we only need the package python-telegram-bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants