0

After running pip3 install python-telegram-bot in command prompt, I get 'telegram' module is not found when I run python -m telegram after the installation.

I have Python 3.9 and 3.10.1 installed, and it seems like the package is installed in the Python 3.9 directory as the output during the installation shows ...pythonsoftwarefoundation.python.3.9

I am new to programming, so I am at a lost as to how to install it for Python 3.10.1. Appreciate any guidance I can get.

Paul Chen
  • 1
  • 1
  • What if you run `python3 -m telegram`? – RJ Adriaansen Jan 22 '22 at 06:33
  • Does this answer your question? [Install a module using pip for specific python version](https://stackoverflow.com/questions/10919569/install-a-module-using-pip-for-specific-python-version) – CallMeStag Jan 22 '22 at 07:31
  • @RJAdriaansen It showed: `The system cannot find the file...` Thanks nonetheless. – Paul Chen Jan 24 '22 at 23:40
  • @CallMeStag Not exactly. Calling the Python version didn't work for me. It showed: `The system cannot find the file...` But reading the post helped me to understand what was wrong. Now I get it. Thanks. – Paul Chen Jan 24 '22 at 23:40

1 Answers1

0

Since you installed the module through pip3 there is a chance you just need to use python3. Try python3 -m telegram.
Opposite it might be that you need to use pip install python-telegram-bot for it to work with python.
Usually pip is linked to python and pip3 is linked to python3 but it is only a guideline, not a rule.

If that doesn't work you can always invoke pip for the other python binary with python -m pip install python-telegram-bot

Mikael Kjær
  • 670
  • 3
  • 6
  • `python -m pip install python-telegram-bot` worked for me as that is the path that is recognised as where my latest version of Python 3.10.1 is installed. Thanks a lot @Mikael. – Paul Chen Jan 24 '22 at 23:43
  • For anyone using PyCharm who still gets `ModuleNotFoundError: No module named 'telegram'` after successfully installing it, remember to check on **Inherit global site-packages** when creating a new project. – Paul Chen Jan 25 '22 at 00:52