alexander-akhmetov / python-telegram

Python client for the Telegram's tdlib
MIT License
610 stars 122 forks source link

ModuleNotFoundError: No module named 'telegram.client'; 'telegram' is not a package #120

Closed LeonardoRick closed 4 years ago

LeonardoRick commented 4 years ago
from telegram.client import Telegram

tg = Telegram(
    api_id='<myid>',
    api_hash='<my-hash>',
    phone='<my-phone>'

)
tg.login()

I keep receiving this error:

    from telegram.client import Telegram
ModuleNotFoundError: No module named 'telegram.client'; 'telegram' is not a package

I tried both:

pip install python-telegram
python3 -m pip install python-telegram

On Linux and Windows. Instalation log:

python --version
Python 3.8.5
pip install python-telegram
Collecting python-telegram
  Downloading https://files.pythonhosted.org/packages/6d/88/e6d70e74ae7febcfdf56431cff93aa4851f1d758114f1bd4ebd808d2c609/python-telegram-0.12.0.tar.gz (11.8MB)
    100% |████████████████████████████████| 11.8MB 129kB/s 
Building wheels for collected packages: python-telegram
  Running setup.py bdist_wheel for python-telegram ... done
  Stored in directory: /home/leonardo/.cache/pip/wheels/7e/8f/3b/05e65b58bc2c7933f7b3b86bbb914fd4a5124edd3ad7caeb4d
Successfully built python-telegram
Installing collected packages: python-telegram
Successfully installed python-telegram-0.12.0
python -m pip install python-telegram
Collecting python-telegram
Installing collected packages: python-telegram
Successfully installed python-telegram-0.12.0
python3 -m pip install python-telegram
Collecting python-telegram
Installing collected packages: python-telegram
Successfully installed python-telegram-0.12.0
~/.local/lib/python3.8/site-packages$ ls
astroid                                  iqoptionapi-6.8.9.1.egg-info       python_telegram-0.12.0.dist-info
astroid-2.4.2.dist-info                  isort                              requests
certifi                                  isort-4.3.21.dist-info             requests-2.24.0.dist-info
certifi-2020.6.20.dist-info              lazy_object_proxy                  six-1.15.0.dist-info
chardet                                  lazy_object_proxy-1.4.3.dist-info  six.py
chardet-3.0.4.dist-info                  mccabe-0.6.1.dist-info             telegram
dns                                      mccabe.py                          tests
dnspython-1.16.0.dist-info               monotonic-1.5.dist-info            toml
eventlet                                 monotonic.py                       toml-0.10.1.dist-info
eventlet-0.26.1.dist-info                numpy                              urllib3
greenlet-0.4.16.dist-info                numpy-1.19.1.dist-info             urllib3-1.25.10.dist-info
greenlet.cpython-38-x86_64-linux-gnu.so  numpy.libs                         websocket
idna                                     __pycache__                        websocket_client-0.56.0.dist-info
idna-2.10.dist-info                      pylint                             wrapt
pylint-2.5.3.dist-info             wrapt-1.12.1.dist-info

Apparently everything is just fine, but my program doesn't run

alexander-akhmetov commented 4 years ago

Hi!

Is the file with your program named telegram.py? Or maybe there is another file near your script with this name? If yes, you need to rename it, it conflicts with the package name.

LeonardoRick commented 4 years ago

I can't beleive it was that. Thanks a lot man. Solved.