Python3 ERROR:no module named telebot after pip installed it - python

python 3.5.2 // Ubuntu 16.04 LTS
I've installed pyTelegramBotAPI to code bots for telegram using this command:
pip instal pyTelegramBotAPI
Result:
Collecting pyTelegramBotAPI
Requirement already satisfied: six in /home/username/.local/lib/python2.7/site-packages (from pyTelegramBotAPI) (1.11.0)
Collecting requests (from pyTelegramBotAPI)
Using cached https://files.pythonhosted.org/packages/49/df/50aa1999ab9bde74656c2919d9c0c085fd2b3775fd3eca826012bef76d8c/requests-2.18.4-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests->pyTelegramBotAPI)
Using cached https://files.pythonhosted.org/packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests->pyTelegramBotAPI)
Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
Collecting idna<2.7,>=2.5 (from requests->pyTelegramBotAPI)
Using cached https://files.pythonhosted.org/packages/27/cc/6dd9a3869f15c2edfab863b992838277279ce92663d334df9ecf5106f5c6/idna-2.6-py2.py3-none-any.whl
Collecting urllib3<1.23,>=1.21.1 (from requests->pyTelegramBotAPI)
Using cached https://files.pythonhosted.org/packages/63/cb/6965947c13a94236f6d4b8223e21beb4d576dc72e8130bd7880f600839b8/urllib3-1.22-py2.py3-none-any.whl
Installing collected packages: certifi, chardet, idna, urllib3, requests, pyTelegramBotAPI
Then, I imported it into my source code:
import telebot
However, when I run the code I get the following error:
Traceback (most recent call last):
File "firstBot.py", line 1, in <module>
import telebot
ImportError: No module named 'telebot'

It mostly happens for Linux Users, because there is a preinstalled python(version 2.x) in the shell, When you install a new module or run your app with default python, it runs and serves by python2.x.
You should use pip3 when you installing it, or run your app by python3 app_main_file.py

Related

Import excel2img gives ModuleNotFoundError

After I did pip install excel2img , I am trying to run import excel2img but getting
'ModuleNotFoundError: No module named 'excel2img' .
The python version that I am running is 3.8.5
even tried pip install pypiwin32 based on the error that I received while installing excel2img but of no help
Any help?
More info on error message
Collecting excel2img
Using cached excel2img-1.4.0.tar.gz (24 kB)
Requirement already satisfied: Pillow>=3.3.1 in /Applications/anaconda3/lib/python3.8/site-packages (from excel2img) (8.0.1)
Collecting pypiwin32
Using cached pypiwin32-223-py3-none-any.whl (1.7 kB)
ERROR: Could not find a version that satisfies the requirement pywin32>=223 (from pypiwin32->excel2img) (from versions: none)
ERROR: No matching distribution found for pywin32>=223 (from pypiwin32->excel2img)```

Can't install Flask-Enterprise for python 3.6 on Ubuntu 18.04

I have an Ubuntu 18.04 operating system with two versions of python installed; 3.6 and 2.7. I tried to install Flask-Enterprise for python 3.6 and I got:
zeinab#ZiZi:~/PycharmProjects/My_Service$ sudo pip3 install Flask-Enterprise
The directory '/home/zeinab/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/zeinab/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting Flask-Enterprise
Downloading https://files.pythonhosted.org/packages/a7/8d/635300aaae97541c8734b83acb4534cbfd879fcf2e2d3f31ced4c3524274/Flask-Enterprise-1.0.tar.gz (78kB)
100% |████████████████████████████████| 81kB 359kB/s
Requirement already satisfied: Flask>=0.3 in /usr/local/lib/python3.6/dist-packages (from Flask-Enterprise)
Collecting soaplib (from Flask-Enterprise)
Downloading https://files.pythonhosted.org/packages/b9/96/44957abd425b50e69848e43ab2c472839390038e3ede611346110b83a2da/soaplib-1.0.0.tar.gz
Collecting suds (from Flask-Enterprise)
Downloading https://files.pythonhosted.org/packages/bc/d6/960acce47ee6f096345fe5a7d9be7708135fd1d0713571836f073efc7393/suds-0.4.tar.gz (104kB)
100% |████████████████████████████████| 112kB 940kB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-7fa4v00d/suds/setup.py", line 20, in <module>
import suds
File "/tmp/pip-build-7fa4v00d/suds/suds/__init__.py", line 154, in <module>
import client
ModuleNotFoundError: No module named 'client'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-7fa4v00d/suds/
But when I install it for python 2.7, everything works fine:
zeinab#ZiZi:~/PycharmProjects/My_Service$ sudo pip2 install Flask-Enterprise
The directory '/home/zeinab/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/zeinab/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting Flask-Enterprise
Downloading https://files.pythonhosted.org/packages/a7/8d/635300aaae97541c8734b83acb4534cbfd879fcf2e2d3f31ced4c3524274/Flask-Enterprise-1.0.tar.gz (78kB)
100% |████████████████████████████████| 81kB 379kB/s
Requirement already satisfied: Flask>=0.3 in /usr/local/lib/python2.7/dist-packages (from Flask-Enterprise)
Collecting soaplib (from Flask-Enterprise)
Downloading https://files.pythonhosted.org/packages/b9/96/44957abd425b50e69848e43ab2c472839390038e3ede611346110b83a2da/soaplib-1.0.0.tar.gz
Collecting suds (from Flask-Enterprise)
Downloading https://files.pythonhosted.org/packages/bc/d6/960acce47ee6f096345fe5a7d9be7708135fd1d0713571836f073efc7393/suds-0.4.tar.gz (104kB)
100% |████████████████████████████████| 112kB 941kB/s
Requirement already satisfied: Werkzeug>=0.14 in /usr/local/lib/python2.7/dist-packages (from Flask>=0.3->Flask-Enterprise)
Requirement already satisfied: click>=5.1 in /usr/local/lib/python2.7/dist-packages (from Flask>=0.3->Flask-Enterprise)
Requirement already satisfied: Jinja2>=2.10 in /usr/local/lib/python2.7/dist-packages (from Flask>=0.3->Flask-Enterprise)
Requirement already satisfied: itsdangerous>=0.24 in /usr/local/lib/python2.7/dist-packages (from Flask>=0.3->Flask-Enterprise)
Requirement already satisfied: lxml>=2.2.1 in /usr/local/lib/python2.7/dist-packages (from soaplib->Flask-Enterprise)
Collecting pytz (from soaplib->Flask-Enterprise)
Downloading https://files.pythonhosted.org/packages/61/28/1d3920e4d1d50b19bc5d24398a7cd85cc7b9a75a490570d5a30c57622d34/pytz-2018.9-py2.py3-none-any.whl (510kB)
100% |████████████████████████████████| 512kB 1.0MB/s
Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib/python2.7/dist-packages (from Jinja2>=2.10->Flask>=0.3->Flask-Enterprise)
Installing collected packages: pytz, soaplib, suds, Flask-Enterprise
Running setup.py install for soaplib ... done
Running setup.py install for suds ... done
Running setup.py install for Flask-Enterprise ... done
Successfully installed Flask-Enterprise-1.0 pytz-2018.9 soaplib-1.0.0 suds-0.4
I found this answer and I installed suds-jurko as an alternative for suds, then tried to install Flask-Enterprise again; I got the same error.
EDIT 1:
I tried to install it in a virtual environment, but I got identical results:
zeinab#Snapp:~$ virtualenv -p python3 testenv
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/zeinab/testenv/bin/python3
Also creating executable in /home/zeinab/testenv/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
zeinab#Snapp:~$ source testenv/bin/activate
(testenv) zeinab#Snapp:~$ pip3 install Flask-Enterprise
Collecting Flask-Enterprise
Downloading https://files.pythonhosted.org/packages/a7/8d/635300aaae97541c8734b83acb4534cbfd879fcf2e2d3f31ced4c3524274/Flask-Enterprise-1.0.tar.gz (78kB)
100% |████████████████████████████████| 81kB 407kB/s
Collecting Flask>=0.3 (from Flask-Enterprise)
Using cached https://files.pythonhosted.org/packages/7f/e7/08578774ed4536d3242b14dacb4696386634607af824ea997202cd0edb4b/Flask-1.0.2-py2.py3-none-any.whl
Collecting soaplib (from Flask-Enterprise)
Downloading https://files.pythonhosted.org/packages/b9/96/44957abd425b50e69848e43ab2c472839390038e3ede611346110b83a2da/soaplib-1.0.0.tar.gz
Collecting suds (from Flask-Enterprise)
Downloading https://files.pythonhosted.org/packages/bc/d6/960acce47ee6f096345fe5a7d9be7708135fd1d0713571836f073efc7393/suds-0.4.tar.gz (104kB)
100% |████████████████████████████████| 112kB 1.1MB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-8am_aqio/suds/setup.py", line 20, in <module>
import suds
File "/tmp/pip-install-8am_aqio/suds/suds/__init__.py", line 154, in <module>
import client
ModuleNotFoundError: No module named 'client'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-8am_aqio/suds/
create a virtual environment by using virtualenv or pipenv.
simply run:
virtualenv -p python3 envname
use this newly created python3 environment as your project interpreter/environment.
open terminal and run following command to activate your environment:
source envname/bin/activate
now install Flask-Enterprise in this virtualenv by using:
pip3 install Flask-Enterprise

Getting python ImportError: cannot import name 'appengine'

I have single line in my py file:
from requests_toolbelt.multipart.encoder import MultipartEncoder
When I run it, I am getting following error:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/requests_toolbelt/_compat.py", line 49, in <module>
from requests.packages.urllib3.contrib import appengine as gaecontrib
ImportError: cannot import name 'appengine'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\workspaces\workspace6\Expe\Exp.py", line 8, in <module>
from requests_toolbelt.multipart.encoder import MultipartEncoder
File "/usr/lib/python3.6/site-packages/requests_toolbelt/__init__.py", line 12, in <module>
from .adapters import SSLAdapter, SourceAddressAdapter
File "/usr/lib/python3.6/site-packages/requests_toolbelt/adapters/__init__.py", line 12, in <module>
from .ssl import SSLAdapter
File "/usr/lib/python3.6/site-packages/requests_toolbelt/adapters/ssl.py", line 16, in <module>
from .._compat import poolmanager
File "/usr/lib/python3.6/site-packages/requests_toolbelt/_compat.py", line 51, in <module>
from urllib3.contrib import appengine as gaecontrib
ImportError: cannot import name 'appengine'
I have just installed requests_toolbelt in cygwin on Windows:
$ pip3 install requests-toolbelt
Collecting requests-toolbelt
Downloading https://files.pythonhosted.org/packages/97/8a/d710f792d6f6ecc089c5e55b66e66c3f2f35516a1ede5a8f54c13350ffb0/requests_toolbelt-0.8.0-py2.py3-none-any.whl (54kB)
100% |████████████████████████████████| 61kB 841kB/s
Requirement already satisfied: requests<3.0.0,>=2.0.1 in /usr/lib/python3.6/site-packages (from requests-toolbelt)
Requirement already satisfied: urllib3==1.20 in /usr/lib/python3.6/site-packages (from requests<3.0.0,>=2.0.1->requests-toolbelt)
Installing collected packages: requests-toolbelt
Successfully installed requests-toolbelt-0.8.0
You are using pip version 9.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Also note that I am running behind proxy.
I am running python 3.6.4:
$ python3
Python 3.6.4 (default, Jan 7 2018, 15:53:53)
[GCC 6.4.0] on cygwin
Considering all these, I am not sure why I am getting this error. Is it like requests_toolbelt have dependency appengine which is not installed? But it would have been installed while installing requests_toolbelt, right?
Update
I was getting above error when I am running the python file in eclipse with PyDev plugin. However I just tried running the same line through python shell >>> in cygwin command prompt and its giving same error.
Update 2
Tried installing same on python under Windows (not on cygwin) and it worked:
C:\Users\user1>pip install requests-toolbelt
Collecting requests-toolbelt
Downloading https://files.pythonhosted.org/packages/97/8a/d710f792d6f6ecc089c5e55b66e66c3f2f35516a1ede5a8f54c13350ffb0/requests_toolbelt-0.8.0-py2.py3-none-any.whl (54kB)
100% |████████████████████████████████| 61kB 1.7MB/s
Collecting requests<3.0.0,>=2.0.1 (from requests-toolbelt)
Downloading https://files.pythonhosted.org/packages/65/47/7e02164a2a3db50ed6d8a6ab1d6d60b69c4c3fdf57a284257925dfc12bda/requests-2.19.1-py2.py3-none-any.whl (91kB)
100% |████████████████████████████████| 92kB 1.9MB/s
Collecting chardet<3.1.0,>=3.0.2 (from requests<3.0.0,>=2.0.1->requests-toolbelt)
Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
100% |████████████████████████████████| 143kB 2.4MB/s
Collecting urllib3<1.24,>=1.21.1 (from requests<3.0.0,>=2.0.1->requests-toolbelt)
Downloading https://files.pythonhosted.org/packages/bd/c9/6fdd990019071a4a32a5e7cb78a1d92c53851ef4f56f62a3486e6a7d8ffb/urllib3-1.23-py2.py3-none-any.whl (133kB)
100% |████████████████████████████████| 143kB 2.4MB/s
Collecting certifi>=2017.4.17 (from requests<3.0.0,>=2.0.1->requests-toolbelt)
Downloading https://files.pythonhosted.org/packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl (150kB)
100% |████████████████████████████████| 153kB 1.5MB/s
Collecting idna<2.8,>=2.5 (from requests<3.0.0,>=2.0.1->requests-toolbelt)
Downloading https://files.pythonhosted.org/packages/4b/2a/0276479a4b3caeb8a8c1af2f8e4355746a97fab05a372e4a2c6a6b876165/idna-2.7-py2.py3-none-any.whl (58kB)
100% |████████████████████████████████| 61kB 1.4MB/s
Installing collected packages: chardet, urllib3, certifi, idna, requests, requests-toolbelt
Successfully installed certifi-2018.4.16 chardet-3.0.4 idna-2.7 requests-2.19.1 requests-toolbelt-0.8.0 urllib3-1.23
You are using pip version 9.0.2, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
C:\Users\user1>python
Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from requests_toolbelt.multipart.encoder import MultipartEncoder
>>>
Still guessing why it was not working on cygwin.
This seems to be an issue in requests_toolbelt which might be fixed in 0.7.1.
Try to install newest version of it.
https://github.com/mvantellingen/python-zeep/issues/413

Issues importing python-pptx on Linux (Ubuntu 17)

I am trying to import the python pptx library in a python programm. I installed it using pip before, which gave me the following output:
Collecting python-pptx
Downloading python-pptx-0.6.6.tar.gz (8.4MB)
100% |████████████████████████████████| 8.4MB 132kB/s
Collecting Pillow>=2.6.1 (from python-pptx)
Downloading Pillow-4.2.1-cp27-cp27mu-manylinux1_x86_64.whl (5.8MB)
100% |████████████████████████████████| 5.8MB 193kB/s
Collecting XlsxWriter>=0.5.7 (from python-pptx)
Downloading XlsxWriter-0.9.8-py2.py3-none-any.whl (137kB)
100% |████████████████████████████████| 143kB 1.2MB/s
Collecting lxml>=3.1.0 (from python-pptx)
Downloading lxml-3.8.0-cp27-cp27mu-manylinux1_x86_64.whl (6.8MB)
100% |████████████████████████████████| 6.8MB 166kB/s
Collecting olefile (from Pillow>=2.6.1->python-pptx)
Downloading olefile-0.44.zip (74kB)
100% |████████████████████████████████| 81kB 1.3MB/s
Building wheels for collected packages: python-pptx, olefile
Running setup.py bdist_wheel for python-pptx ... done
Stored in directory: /home/clemens/.cache/pip/wheels/27/f8 /dc/181ed5439001413ee0c1c8794a06009c4c0b96f652401e2d20
Running setup.py bdist_wheel for olefile ... done
Stored in directory: /home/clemens/.cache/pip/wheels/20/58 /49/cc7bd00345397059149a10b0259ef38b867935ea2ecff99a9b
Successfully built python-pptx olefile
Installing collected packages: olefile, Pillow, XlsxWriter, lxml, python-pptx
Successfully installed Pillow-4.2.1 XlsxWriter-0.9.8 lxml-3.8.0 olefile-0.44 python-pptx-0.6.6
So this seems to be a success.
But as I am trying to import the module using the following code:
try:
from pptx import Presentation
except Exception as e:
print(e)
It says No module named 'pptx'.
It must have something to do with Linux since the same code works just fine on windows and the module seems to be installed correctly. I am using Python 3.5.3.
Using pip install, you'll install it for Python2, not for Python3. To make sure it gets installed for Python3, invoke pip from the interpreter, like this:
python3 -m pip install <package>

Python Twisted twisted.internet

I've downloaded twisted from git
git clone -b trunk https://github.com/twisted/twisted.git
as http://twistedmatrix.com/trac/wiki/Downloads suggests.
And then I performed
sudo python setup.py install
But now when I run some python files I get
ImportError: No module named twisted.internet.
I've also noticed, in the README.rst of git, that it doens't mention the module twisted.internet.
So where should I get it?
Don't ever sudo pip install ... anything. Use virtualenv instead.
exarkun#baryon:~$ virtualenv /tmp/virtualenv-demo
Running virtualenv with interpreter /usr/bin/python2
New python executable in /tmp/virtualenv-demo/bin/python2
Also creating executable in /tmp/virtualenv-demo/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
exarkun#baryon:~$ . /tmp/virtualenv-demo/bin/activate
(virtualenv-demo) exarkun#baryon:~$ pip install twisted
Collecting twisted
Collecting constantly>=15.1 (from twisted)
Using cached constantly-15.1.0-py2.py3-none-any.whl
Collecting zope.interface>=3.6.0 (from twisted)
Collecting Automat>=0.3.0 (from twisted)
Using cached Automat-0.5.0-py2.py3-none-any.whl
Collecting incremental>=16.10.1 (from twisted)
Using cached incremental-16.10.1-py2.py3-none-any.whl
Requirement already satisfied: setuptools in /tmp/virtualenv-demo/lib/python2.7/site-packages (from zope.interface>=3.6.0->twisted)
Collecting attrs (from Automat>=0.3.0->twisted)
Using cached attrs-16.3.0-py2.py3-none-any.whl
Requirement already satisfied: six in /tmp/virtualenv-demo/lib/python2.7/site-packages (from Automat>=0.3.0->twisted)
Requirement already satisfied: appdirs>=1.4.0 in /tmp/virtualenv-demo/lib/python2.7/site-packages (from setuptools->zope.interface>=3.6.0->twisted)
Requirement already satisfied: packaging>=16.8 in /tmp/virtualenv-demo/lib/python2.7/site-packages (from setuptools->zope.interface>=3.6.0->twisted)
Requirement already satisfied: pyparsing in /tmp/virtualenv-demo/lib/python2.7/site-packages (from packaging>=16.8->setuptools->zope.interface>=3.6.0->twisted)
Installing collected packages: constantly, zope.interface, attrs, Automat, incremental, twisted
Successfully installed Automat-0.5.0 attrs-16.3.0 constantly-15.1.0 incremental-16.10.1 twisted-17.1.0 zope.interface-4.3.3
(virtualenv-demo) exarkun#baryon:~$ python -c 'import twisted.internet; print twisted.internet'
<module 'twisted.internet' from '/tmp/virtualenv-demo/local/lib/python2.7/site-packages/twisted/internet/__init__.pyc'>
(virtualenv-demo) exarkun#baryon:~$ deactivate
exarkun#baryon:~$

Categories

Resources