2
votes

When I try to run a bot, I get this error message in the terminal:

zass@zass-system-product-name:~/python-telegram-bot/examples$python 
echobot.py
/usr/local/lib/python2.7/dist-packages/python_telegram_bot-8.0-
py2.7.egg/telegram/utils/request.py:38: UserWarning: python-telegram-
bot wasn't properly installed. Please refer to README.rst on how to 
properly install.
Traceback (most recent call last):
File "echobot.py", line 8, in <module>
import telegram 
File "build/bdist.linux-x86_64/egg/telegram/__init__.py", line 94, in 
<module>
File "build/bdist.linux-x86_64/egg/telegram/bot.py", line 34, in 
<module>
File "build/bdist.linux-x86_64/egg/telegram/utils/request.py", line 
33, in <module>
ImportError: No module named ptb_urllib3.urllib3

I'm running Python 2.7 on ubuntu, git and telegram bot are installed. - How can I fix it?

3
Did you install urllib3? - amarynets
yes i installed urllib3 - Sami Soheili
Do you use virtualenv? If yes, probably you didn't activate it - amarynets
oh no can you explain what i must do please ? - Sami Soheili
If you run pip freeze you should see urllib3 in a list. If there will not be this lib - you haven't installed it, or os block your installation because you aren't root user. You should use sudo pip install urlib3. If you don't know what is virtualenv - you don't use it) - amarynets

3 Answers

0
votes

First of all make sure you have urllib3 installed. Sometimes urllib3 installation breaks. If for some reason your install of urllib3 is failing to include the util submodule, you could simply download the archive from the pypi page and copy the util folder from there to your urllib3 install location.

You may also issue the command below to get an up-to-date version:

sudo pip install urllib3 --upgrade

Then, see where your module is by starting a python interpreter and check where the urllib3 module is being loaded from:

python -c "import urllib3; print urllib3.__file__"

If all the above didn't work for you, make sure you're importing it right! and make sure there is no conflict.

0
votes

If you clone the python-telegram-bot repo you need to run the following command before installing the code:

git submodule update --init --recursive

Then install the code with python setup.py install

0
votes

Maybe you have 2 version of python and default version is 3.x Try to check version of python python -V if default version is 3 then run your code with python version 2.

python2 echobot.py

it can be python2 or python2.7

Also it can be cause of versions of libs