Failed to import a module - python

I try to use ImageGrab (open-cv function)
OS: lubuntu
First, I did: sudo apt-get install python-opencv.
Installation went successfuly.
Then I tried to do: from PIL import ImageGrab. But at this point I got the following ImportError:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/user/lib/python2.7/dist-packages/PIL/ImageGrab.py", line 26, in <module> import _grabscreen
ImportError: No module named _grabscreen
Where am I wrong?

Unfortunately - ImageGrab only works with Windows
Alternative: pyscreenshot

Related

ModuleNotFoundError: No module named 'PIL' ,During handling of the above exception, another exception occurred:

I was using pytesseract for OCR from images. Everything was working fine .. till I tried pip install pillow and pip easy install pillow in my cmd just for trying a random crop . After that when I try to import pytesseract. It keeps throwing error
Traceback (most recent call last):
File "C:\Python39\lib\site-packages\pytesseract\pytesseract.py", line 28, in <module>
from PIL import Image
ModuleNotFoundError: No module named 'PIL'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import pytesseract
File "C:\Python39\lib\site-packages\pytesseract\__init__.py", line 2, in <module>
from .pytesseract import ALTONotSupported
File "C:\Python39\lib\site-packages\pytesseract\pytesseract.py", line 30, in <module>
import Image
ModuleNotFoundError: No module named 'Image'
You are using Python 3.9 version. Pillow is compatible with that but only from v8. Check your pillow version. If its below 8, update it using:
>>pip install --upgrade Pillow
Moreover, if the 2nd error still persists, try this:
from PIL import Image
instead of
import Image

Python + RaspberryPI can't import GPIO after installing: ImportError: No module named _GPIO

I have a RPi 2 (running raspbian jessie with pixel) and just tried to install the GPIO module:
I have downloaded and installed from source. Then I issue commands:
pi#raspberry:python
>>> import RPi.GPIO as GPIO
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "RPi/GPIO/__init__.py", line 23, in <module>
from RPi._GPIO import *
ImportError: No module named _GPIO
so then I tried using sudo:
pi#raspberry:sudo python
>>> import RPi.GPIO as GPIO
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "RPi/GPIO/__init__.py", line 23, in <module>
from RPi._GPIO import *
ImportError: No module named _GPIO
Then I removed the module from python, and installed it again using pip:
pi#raspberry:sudo pip install RPi.GPIO
pi#raspberry:sudo python
>>> import RPi.GPIO as GPIO
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "RPi/GPIO/__init__.py", line 23, in <module>
from RPi._GPIO import *
ImportError: No module named _GPIO
Then I removed the module from python, and installed it again using apt-get:
pi#raspberry:sudo apt-get update
pi#raspberry:sudo apt-get -y install python-rpi.gpio
pi#raspberry:sudo python
>>> import RPi.GPIO as GPIO
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "RPi/GPIO/__init__.py", line 23, in <module>
from RPi._GPIO import *
ImportError: No module named _GPIO
It seems it has nothing to do with the install method, so I'm assuming it's something to do with either Raspbian Jessie + pixel or the current version of python-gpio is broken/incompatible.
Its strange because I am not importing "_GPIO", I am importing "GPIO", which indicates to me that my python syntax is not the culprit.
Could somebody please recommend what I should try next?
Also I searched this exact error on Google and got 1 result which was not helpful.
Thanks,
i think you have a dir called RPi in your current dir,so change your python file to another dir which doesn't have ,it works for me...hope it's helpful :)

Can't import the py-translate 1.03 package

Is someone familiar with these package?
I tried easy install and many things I saw in imports problems solution
>>> import translate
output:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import translate
File "C:\Python27\lib\site-packages\translate\__init__.py", line 8, in <module>
from .translator import *
File "C:\Python27\lib\site-packages\translate\translator.py", line 13, in <module>
import requests
ImportError: No module named requests
Moreover, in the directory of the package there is a test file.
I tried to run it but I got this:
Traceback (most recent call last):
File "C:\Python27\Lib\site-packages\translate\tests\test_translator.py", line 10, in <module>
from ..translator import translator
ValueError: Attempted relative import in non-package
How have you installed py-translate.
It requires: requests
My advice is pip install requests (or easy_install requests)
Their latest release is 1.0.2, but also goes by 1.0.3.
Pip install the package, don't just download the archive as you will miss the dependancies

matplotlib gives ImportError: No module named six

I am using python 2.7 with matplotlib 1.4.3. When I try to run a simple program I get this error:
Traceback (most recent call last):
File "C:\Python27\Projects\ImgRecg\img.py", line 3, in <module>
import matplotlib.pyplot
File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 105, in <module>
import six
ImportError: No module named six
You need to install the Six module.
pip install six

ImportError: cannot import name ResourceError

I'm trying to install couchdb app on debian using the following command
couchapp push http://user:pass#localhost:5984/acra-appname
and I'm having the following error output:
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/restkit/__init__.py", line 9, in <module>
from restkit.conn import Connection
File "/usr/local/lib/python2.6/dist-packages/restkit/conn.py", line 14, in <module>
from socketpool import Connector
ImportError: No module named socketpool
Traceback (most recent call last):
File "/usr/local/bin/couchapp", line 7, in <module>
from couchapp.dispatch import run
File "/usr/local/lib/python2.6/dist-packages/couchapp/dispatch.py", line 10, in <module>
import couchapp.commands as commands
File "/usr/local/lib/python2.6/dist-packages/couchapp/commands.py", line 15, in <module>
from couchapp import clone_app
File "/usr/local/lib/python2.6/dist-packages/couchapp/clone_app.py", line 15, in <module>
from couchapp.errors import AppError
File "/usr/local/lib/python2.6/dist-packages/couchapp/errors.py", line 7, in <module>
from restkit import ResourceError
ImportError: cannot import name ResourceError
As far as I understand the error is:
ImportError: No module named socketpool
How can I install this module or how to resolve the problem?
As Ifthikhan sugessted: Install it using a package manager such as apt-get and thereafter using pip you can install socketpool.
I had this problem when installing couchapp. I used pip to install it, and I thought it completed, but when I ran it I had the ImportError problem. Turns out the pip install didn't succeed and I first needed to:
apt-get install python-dev
Then when I did a
pip install couchapp
all of the dependencies were installed and couchapp ran without a problem.

Categories

Resources