简体   繁体   中英

How to fix problem of “ModuleNotFoundError: No module named 'PIL'”?

I tried with the solution given in 'stackoverflow', but not resolved.

I am trying to extract text from images with the help of pytesseract module from python.

The following are the steps I followed:

code:

py -m pip install --user virtualenv
py -m venv tessa #creating virtual environment
c:\Users\folder\tessa\Scripts>activate #activated virtual environment
(tessa) c:\Users\folder>jupyter notebook #initiated jupyter IDE
pip install opencv-python
pip install pytesseract
import pytesseract
pytesseract.pytesseract.tesseract_cmd = r'C:\\Users\\folder\\subfolder\\Local\\Programs\\Tesseract-OCR\\tesseract.exe'

Now problem start as shown in the image uploaded here in.

错误截图

Also showing error 'ModuleNotFoundError: No module named "Image"'

I am not able to fix this issue. Can anybody help on this error, to fix it?

Thanks a lot.

It is saying that the module named Pillow(PIL) is missing. You can install it using pip. Enter the following in Command Line.

pip install Pillow

You are lacking the module Pillow. To install it you can run the following command in your command line:

py -m pip install Pillow

Make sure you are doing this when your environment is active (after using the activate command), otherwise you will be installing it on your Python globally.

Some modules of Python are pre-installed, but no all. You can find modules index this official index . Then (if you have added pip to your path when you was installing Python), go to your terminal (cmd in Windows) and execute:

pip install [module_name]

Then don't forget to import it in your code

If you have want to share your projet, mark all modules used in a file named "requirements.txt" like that . Then the other user just have to execute

pip install -r requirements.txt

And modules will installed in the good version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM