No module named image windows

Error:ModuleNotFoundError: No module named ‘Image’

I am getting the following error:

ModuleNotFoundError: No module named ‘Image’

while running the below script for OCR:

I am using Spider through Anaconda and have Pillow installed.

2 Answers 2

Have a look at the docs, where you can see some basic examples. In short: You need to specify that you are importing Image from PIL :

You should install pytesseract use pip (also see guide):

or use python cross-platform module tesseract :

and use it as you have in your question:

Not the answer you’re looking for? Browse other questions tagged python image image-processing ocr or ask your own question.

Linked

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.4.16.39093

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

import Image ImportError: No module named Image #2

Comments

dixon1e commented Aug 8, 2016

When using pillow on Mac OS X Yosemite this error occurs. Solution is to change in cnnimg.py

The text was updated successfully, but these errors were encountered:

ankitaggarwal011 commented Aug 8, 2016

Thanks a lot for reporting the issue. I appreciate it.

I’m aware that the Image library is no longer supported and is incompatible with Python 3. Pillow is an obvious replacement and its in the pipeline. However, I’m unable to get time to change the library from Image to Pillow. This would require updated import instructions and whether its consistent with the earlier usage of Image library. This is in the pipeline, however, if you’re interested in the updating this library from Image to PIL, I would really appreciate. Please let me know. Thanks again.

Читайте также:  Готовые звуковые схемы для windows 10

dixon1e commented Aug 8, 2016

Thank you for reaching out. I posted the issue mainly to have a placeholder
for the error. Hopefully Mac users will see this and get a quick fix as
they try the code.

My main interest is processing images and finding objects, currently a
place where Convolutional NN’s are big. I’ll check back in with you if I
get time to work on this.

On Mon, Aug 8, 2016 at 1:29 AM, Ankit Aggarwal notifications@github.com
wrote:

Thanks a lot for reporting the issue. I appreciate it.

I’m aware that the Image library is no longer supported and is
incompatible with Python 3. Pillow is an obvious replacement and its in the
pipeline. However, I’m unable to get time to change the library from Image
to Pillow. This would require updated import instructions and whether its
consistent with the earlier usage of Image library. This is in the
pipeline, however, if you’re interested in the updating this library from
Image to PIL, I would really appreciate. Please let me know. Thanks again.

No Module named PIL

I know PIL is deprecated, so I installed Pillow instead, and for backward compatibility reason, Pillow is still using PIL as its module name. Here’s my pip freeze look like for Pillow: Pillow=3.2.0

Here’s how I use it in my code:

As someone suggested in a similar post, also, I tried

Neither works. Both give me this error:

Help is really appreciated!

7 Answers 7

As per my comment since it helped you out and answered your problem:

The issue that you were seeing is that you had pip version 1.5.6, and the version of pip does dictate how packages are unzipped, which ultimately determines whether or not modules are loaded properly.

All that is needed is:

Which allows pip to upgrade itself.

Use sudo if you’re on Mac/Linux, otherwise you’ll likely need to ‘Run as Administrator’ on Windows.

And voila, you can now properly import the PIL modules:

In my case, on Windows, all I needed to do is to run:

pip install pillow

You can use python -m pip install Pillow or pip install Pillow

I’m having this trouble too recently, so let me share my take on this. I’m on Mac OS X Mojave 10.14. I tried running the pip install pillow so many times blindly without finding deeper understanding as to where my python searches for its packages.

Читайте также:  Установить nvidia для windows 10 64 bit для ноутбука

I encountered this error when I upgraded from OS X High Sierra to Mojave. My previously working Scrapy project just stopped running properly.

Note that I didn’t use virtualenv .

First, you need to check which python is used by the system. In the Terminal, run

You’ll get something similar to this:

nicholaslie$ which -a python /usr/local/bin/python /usr/local/bin/python /usr/bin/python

This leads me to searching inside the /usr/local/ folder. Turns out there’s a folder to where my python is searching its packages, and that is inside /usr/local/lib/python2.7 ( python ) or /usr/local/lib/python3.7 ( python3 )

What my current pip install pillow do is installing the PIL package inside the /usr/local/lib/python2.7/site-packages directory, but not to /usr/local/lib/python3.7/site-packages

However, since my project uses Python 3, No module named PIL error simply tells you that the python3 instance you’re using cannot find the PIL library.

I used Homebrew for managing my system packages such as node , python , etc. So what I did was reinstall python3 with Homebrew with:

brew reinstall python , then run pip3 install pillow .

Just ensure that the PIL package is installed properly in /usr/local/lib/python3.7/site-packages and you should be good to go. Hope this helps someone.

ImportError: No module named bs4 in Windows

I am trying to create a script to download the captcha from my website. I think the code works except from that error, when I run it in cmd (I am using windows not Linux) I receive the following:

I tried using pip install BeautifulSoup4 but then I receive a syntax error at install.

Here is the script:

The problem according to this answer must be due to the fact I have not activated the virtualenv, and THEN install BeautifulSoup4.

I don’t think this information will be of any help but I saved my python text in a notepad.py and the run it using cmd.

4 Answers 4

I had the same problem until a moment ago. Thanks for the post and comments! According to @Martin Vseticka ‘s suggestion I checked if I have the pip.exe file in my python folders. I run python 2.7 and 3.7 simultaneously. I didn’t have it in the python 2.7 folder but in the 3.7. So in the command line I changed the directory to where the pip.exe file was located. Then I ran «pip install BeautifulSoup4» and it worked. See enclosed screen shot.

Читайте также:  Антивирус для windows ultimate

I did a fresh install of Python 3.5 on my Windows 8.1 (64b) machine and then run:

test.py contains only:

I received no error.

I could install bs4, but still got an error message like yours. My operation system is 64 bit, and I only had this issue after I installed the latest Python in «32 bit» version. So I removed the 32 bit one, then I can import the bs4 again, and it still works after I install the latest Python in 64 version. Hope it helps.

I have python3.7 32bit and python3.7 64 bit installed on Windows 10. For this app, I am using the 32 bit version. I was getting the following error:

when I was trying to ‘import bs4’ from my app.py. Someone said: «Make sure your pip and your python are both 32 bits», but omitted to explicitly say how, so here it is:

Delete your virtual environment if it exists.

Create a new venv using python -m venv venv , but explicitly call it from your 32bit python directory like this: C:\Users\me\AppData\Local\Programs\Python\Python37-32\python -m venv my_venv

install the requirements by explicitly calling the 32bit version like this:

Решение проблемы с ошибкой ImportError: No module named requests

Если при запуске программы на Python у вас появляется сообщение об ошибке:

значит у вас отсутствует модуль Requests. Requests не является встроенным модулем, поэтому его нужно загрузить. Официальная документация по модулю: https://pypi.python.org/pypi/requests

OSX/Linux

Если у вас установлен pip, для установки в OSX/Linux используйте команду:

Обратите внимание на версию, чтобы явно указать, для какой версии Python вы делаете установку, используйте pip2 или pip3.

На OSX если у вас установлен easy_install, вы также можете использовать

Windows

В этой операционной системе используйте команду:

Если у вас машина на Windows, где если он был установлен, easy_install может быть найден в вашем каталоге Python*\Scripts. (Помните, Path\easy_install.exe — это пример, моя, к примеру, такая C:\Python32\Scripts\easy_install.exe)

Если у вас Windows машина без установленного easy install, то вы можете получить его здесь: http://www.lfd.uci.edu/

Если вы хотите добавить библиотеку на Windows машине вручную, вы можете загрузить сжатую библиотеку, разархивировать и затем поместить в каталог Lib вашего Python.

Из исходников (универсальный способ)

Любая отсутствующая библиотека, обычно, доступна в исходниках на: https://pypi.python.org/pypi/. Затем:

На mac osx и Windows, после загрузки zip с исходником, распакуйте его и из терминала/cmd запустите

Оцените статью