ModuleNotFoundError: No module named 'telegram.utils' - python

I have installed python-telegram-bot like:
pip install python-telegram-bot
When I'm try to do this:
from telegram.ext import Updater, CommandHandler, MessageHandler, filters
from telegram.utils.helpers import escape_markdown
I get this error:
ModuleNotFoundError: No module named 'telegram.utils'

See telegram sourcecode:
The function escape_markdown is located in telegram/helpers.py, so the correct import should be next:
root#shdebian1:~# python3
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from telegram.helpers import escape_markdown

Related

pypy no module named dateutil

I'm trying to import dateutil in pypy, which I've got the following error. Importing dateutil in python2.7 didn't return an error
[root#]# python
Python 2.7.5 (default, May 31 2018, 09:41:32)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dateutil
>>> exit()
[root#]# pypy
Python 2.7.13 (4a68d8d3d2fc1faec2e83bcb4d28559099092574, Oct 18 2019, 01:09:48)
[PyPy 7.2.0 with GCC 8.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>> import dateutil
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named dateutil
I'm not sure if this is related but dateutil is found in
/usr/lib/python2.7/site-packages
But not found in
/usr/lib64/python2.7/site-packages
pypy on the server is located in
/opt/pypy-7.2.0-linux_x86_64-portable
I tried uninstalling dateutil and reinstalling dateutil using pip, but pypy can't seem to find it.
Would appreciate any help. Thank you in advance!!!
You might be using the wrong pip. When you call pip install ... you will find whichever pip is first on your $PATH, which may not be the one you need. I try to use path/to/pypy -mpip install ... which will ensure you are using the correct one

ModuleNotFoundError: No module named 'tqdm'

Can not run my awesome.py cause:
ModuleNotFoundError: No module named 'tqdm'
(incaelum) C:\Users\inc\Desktop\pruebas\STR_SEARCH>python
Python 3.5.6 |Anaconda, Inc.| (default, Aug 26 2018, 16:05:27) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tqdm
>>>
As u can see i can run python and import tqdm with no errors
I used pip, pip3, conda to install tqdm inside my envoriment:
installation suscesful
I also installed tqdm from anaconda environment manager. no errors as well
but when i run the program i get always the same:
ModuleNotFoundError: No module named 'tqdm'
Am running the py file from my envoriment and getting same error.
Anyone can deal with this?

NLTK, NUMPY and SCIPY - cannot be imported

enter image description here
PS C:\WINDOWS\system32> python
Python 3.7.0a2 (v3.7.0a2:f7ac4fe, Oct 17 2017, 17:06:29) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import sys
>>> import numpy
PS C:\WINDOWS\system32> python
Python 3.7.0a2 (v3.7.0a2:f7ac4fe, Oct 17 2017, 17:06:29) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
PS C:\WINDOWS\system32>
I can not import the mentioned modules however it is not giving any error as well. Even in small program if I import any of these 3 the program just ends without doing anything.
I have only one installation of Python. No other verison.
Update:
PS C:\WINDOWS\system32> pip freeze
boto==2.49.0
boto3==1.9.115
botocore==1.12.115
bz2file==0.98
certifi==2019.3.9
chardet==3.0.4
docutils==0.14
gensim==3.7.1
idna==2.8
jmespath==0.9.4
nltk==3.4
numpy==1.16.2
python-dateutil==2.8.0
requests==2.21.0
s3transfer==0.2.0
scipy==1.2.1
singledispatch==3.4.0.3
six==1.12.0
smart-open==1.8.0
urllib3==1.24.1
PS C:\WINDOWS\system32> python
Python 3.7.0a2 (v3.7.0a2:f7ac4fe, Oct 17 2017, 17:06:29) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print(numpy.__version__)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'numpy' is not defined
>>> exit()
PS C:\WINDOWS\system32>
Maybe I am reading what you have given incorrectly, but the way you have given, you haven’t done any “import numpy” in that Python session before accessing numpy.version. Please confirm.

vagrant/ansible: ImportError: No module named site

I am trying to start a vagrant vm and provision it using its ansible provisioner;
config.vm.provision "ansible" do |ansible|
ansible.limit = "all"
ansible.compatibility_mode = "2.0"
ansible.playbook = "ansible/install.yml"
end
the box is ubuntu/xenial64
Provisioning fails as follows:
==> default: Running provisioner: ansible...
default: Running ansible-playbook...
ImportError: No module named site
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
Host is Ubuntu 16.04.05 with ansible 2.7.0
I even tried to run a shell provisioner that installs python-minimal on the guest before executing ansible, but with no luck.
edit: in the mean time, on my controller:
/home/pkara/Desktop
$ python
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import site
>>>
/home/pkara/Desktop
$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import site
>>>

No module named for requests

I have two Ubuntu servers. Entering below on server Server A works fine:
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> from requests.packages.urllib3.poolmanager import PoolManager
Server B however,
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> from requests.packages.urllib3.poolmanager import PoolManager
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named packages.urllib3.poolmanager
Both have the same version:
Name: requests
Version: 2.7.0
Location: /usr/local/lib/python2.7/dist-packages
Requires:
Whats going on here?
Here is Server B's paths:
/usr/local/lib/python2.7/dist-packages/greenlet-0.4.5-py2.7-linux-x86_64.egg
/usr/local/lib/python2.7/dist-packages/gevent-1.0.1-py2.7-linux-x86_64.egg
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7
/usr/lib/python2.7/plat-x86_64-linux-gnu
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/dist-packages
Thing is the Sever B has the file located here so it should find it:
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3
It's an issue in python-requests as the owners did not package it the same between Pypi and Ubuntu repository as mentioned here.
Solutions:
Use urllib3 directly:
from urllib3.poolmanager import PoolManager
Remove completely all copies of python-requests than re-install it either using pip or using apt-get, the one that includes packages.urllib3 inside.

Categories