modulenotfounderror no module named pil что делать
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
In my case, on Windows, all I needed to do is to run:
pip install pillow
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:
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.
I encountered this error when I upgraded from OS X High Sierra to Mojave. My previously working Scrapy project just stopped running properly.
First, you need to check which python is used by the system. In the Terminal, run
You’ll get something similar to this:
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.
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.
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:
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?
3 Answers 3
It is saying that the module named Pillow(PIL) is missing. You can install it using pip. Enter the following in Command Line.
You are lacking the module Pillow. To install it you can run the following command in your command line:
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 :
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
And modules will installed in the good version.
ImportError: нет модуля с именем PIL
Я использую эту команду в оболочке для установки PIL:
у меня никогда не было такой проблемы, как вы думаете?
16 ответов:
на некоторых установках PIL, вы должны сделать
вместо import PIL (PIL на самом деле не всегда импортируется таким образом). Так как import Image работает для вас, это означает, что вы на самом деле установили PIL.
наличие другого имени для библиотеки и модуля Python необычно, но это то, что было выбрано для (некоторых версий) PIL.
вы можете получить дополнительную информацию о том, как использовать этот модуль из официальный учебник.
PS: на самом деле, на некоторые установка import PIL тут работа, которая добавляет путаницы. Это подтверждается пример из документации, как выяснил @JanneKarila, а также некоторые более поздние версии пакета MacPorts PIL (1.1.7).
внимание: PIL является устаревшим, и подушка является правопреемником.
на другой ноте, я могу настоятельно рекомендовать использование подушка который обратно совместим с PIL и лучше поддерживается/будет работать на более новых системах.
когда это установлено, вы можете сделать
тогда в коде python вы можете вызвать
это сработало для меня на Ubuntu 16.04:
на Wikibooks после поиска в течение примерно получаса.
иногда я получаю этот тип ошибки при запуске Unitest в python. Решение заключается в удалении и установке одного и того же пакета в виртуальной среде.
С помощью этой команды:
Если по какой-либо причине вы получаете сообщение об ошибке, добавьте sudo в начале команды и после нажатия enter введите свой пароль.
в windows попробуйте проверить путь к местоположению библиотеки PIL. В моей системе я заметил, что путь был
вместо пил использовать подушка он работает
вам нужно будет установить образ и подушку с вашим пакетом python. Будьте уверены, командная строка позаботится обо всем за вас.
python-m pip install image
вы должны установить образ и подушку с вашим пакетом python.
или запустите командную строку (в windows), затем перейдите в папку scripts
затем выполните команду ниже
на Windows, вам нужно загрузить его и установить.exe
У меня была такая же проблема при импорте PIL и дальнейшем импорте модулей ImageTk и Image. Я также попытался установить PIL непосредственно через pip. но успеха добиться не удалось. Поскольку между ними было предложено, чтобы PIL был устаревшим, таким образом, попытался установить подушку только через pip. подушка была успешно установлена, далее, пакет PIL был сделан по пути: python27/Lib/site-packages/.
теперь можно импортировать как изображение, так и ImageTk.
Я недавно установил Leap. Я попробовал openshot, и он не начался. Поэтому пришел сюда и нашел предложение начать с терминала, чтобы увидеть, есть ли какие-либо ошибки.
я использовал conda-forge для установки подушки версии 5, и это, казалось, работало для меня:
нормальная подушка установки conda не работала для меня.
вы, вероятно, не хватает заголовков python для построения pil. Если вы используете ubuntu или подобные, это будет что-то вроде
No module named PIL #3851
Comments
cheekysim commented May 14, 2019 •
What did you do?
i did pip install pillow and wrote from PIL import Image
but when i run it it just say no module named PIL
What did you expect to happen?
it would run fine and give no errors
What actually happened?
I got the error «no module named PIL»
What are your OS, Python and Pillow versions?
The text was updated successfully, but these errors were encountered:
radarhere commented May 14, 2019
I don’t suppose that you have two versions of Python set up, and you are installing into one and then trying to import from the other?
cheekysim commented May 14, 2019 •
it is installing for the right version,
i didnt have import PIL but i just tried and same error,
radarhere commented May 15, 2019
Since you have ‘venv’ in your path, I presume that the answer to this question involves the fact that you’re using a virtual environment. https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/ might prove useful.
cheekysim commented May 15, 2019
Here’s the thing:
Pip location : c:\users\cs-admin\appdata\local\programs\python\python36\lib\site-packages
Install location : ‘C:\Users\cs-admin\AppData\Local\Programs\Python\Python36\lib\site-packages’,
Hassani87 commented Dec 22, 2019
change PIL with pil
It works for me
walhekav commented Jan 26, 2020
change PIL with pil
It works for me
simple solution, but it was really pain. Thanks
Escartem commented Jun 18, 2020
sorry to comment on this old question but I already tried this and this was working but now when I do «import PIL» it says «no module named PIL» but when I do «import pil» it gave the same error «no module named PIL» in capital letters.
Lassie23 commented Jun 19, 2020 •
change PIL with pil
It works for me
it doesnt for me.
literally all i want to do is show an image in python.
i have been trying for hours.
someone please help me.
Edit: incase this matters, i went to the file location of where pip said it installed pillow, but couldnt find anything to do with pillow.
Edit 2: actually i found it, it was installed in C: instead of C:\Users \AppData\Local\Programs\Python
thats definitely a bad thing, right? if anyone could please help me i would be so grateful.
Edit 3: ok, now ive fixed it, but its saying «cannot import name ‘_imaging’ from ‘PIL’
that’s weird, as i told it to import «Image», not «_imaging». does anyone have a solution?
Escartem commented Jun 19, 2020
I found a solution that worked for me :
First I uninstalled the old version of pil located for me in %localappdata%\Programs\Python\Python37-32\Lib\site-packages\ and removed the pil folder
Then I updated Pillow using pip install Pillow==7.1.2 and adding the version was necessary because otherwise, it will install the latest version of Pillow that can work for every dependency
And then doing from PIL import Image worked
A4lfr32 commented Jun 25, 2020
change PIL with pil
It works for me
akackon commented Jul 11, 2020
When I exited my virtual environment it seemed to work
ahmedmaz24 commented Aug 11, 2020
danielcovaci commented Sep 4, 2020 •
oh em gi
i have the same problem and nothing seems to work 🙁
vienom commented Sep 16, 2020
For me it was a python version problem. Fixed it by using pip3 install Pillow and then starting the script with python3 script.py
hugovk commented Sep 16, 2020
For me it was a python version problem. Fixed it by using pip3 install Pillow and then starting the script with python3 script.py
PianoPianist commented Oct 15, 2020
Exactly, I tried everything on the internet, nothing seems to work
PianoPianist commented Oct 15, 2020
Thankfully, it’s now working. What I did was, I deleted pip from the location where it was saved, which in my case was:
C:\Users \AppData\Local\Microsoft\WindowsApps. Then I installed it again using this website: https://datatofish.com/upgrade-pip/
This time, I installed it in (I changed the location with the help of that website):
C:\Users \AppData\Local\Programs\Python\Python38-32\Scripts
Then I used pip install pillow and installed it in the same place, Python Scripts area given above. Uninstall it using pip uninstall pillow if it wasn’t already.
Then import PIL in Python and it’ll work!
znym commented Nov 6, 2020
Thankfully, it’s now working. What I did was, I deleted pip from the location where it was saved, which in my case was:
C:\Users\AppData\Local\Microsoft\WindowsApps. Then I installed it again using this website: https://datatofish.com/upgrade-pip/
This time, I installed it in (I changed the location with the help of that website):
C:\Users\AppData\Local\Programs\Python\Python38-32\Scripts
Then I used pip install pillow and installed it in the same place, Python Scripts area given above. Uninstall it using pip uninstall pillow if it wasn’t already.
Then import PIL in Python and it’ll work!
Could you please write down your approach step by step?
I’d like to try this suggestion but I am not sure if I can follow the directions correctly now.
PianoPianist commented Nov 7, 2020
Thankfully, it’s now working. What I did was, I deleted pip from the location where it was saved, which in my case was:
C:\Users\AppData\Local\Microsoft\WindowsApps. Then I installed it again using this website: https://datatofish.com/upgrade-pip/
This time, I installed it in (I changed the location with the help of that website):
C:\Users\AppData\Local\Programs\Python\Python38-32\Scripts
Then I used pip install pillow and installed it in the same place, Python Scripts area given above. Uninstall it using pip uninstall pillow if it wasn’t already.
Then import PIL in Python and it’ll work!
Could you please write down your approach step by step?
I’d like to try this suggestion but I am not sure if I can follow the directions correctly now.
When I installed pillow from command prompt, I just entered the command pip install pillow and not specified any location, so it installed pillow to the default location, which in my case was C:\Users\ \AppData\Local\Microsoft\WindowsApps (I’m pretty sure it’s the same in yours too).
Try importing PIL again in Python, and it should work!
Как исправить ошибку ModuleNotFoundError: no module named pyowm Python 3.7.4?
Всем привет, помогите начинающему кодеру
Windows 10
Устанавливаю модуль по инструкции
pip install pyowm
Код в файле программы:
Средний 12 комментариев
Найдите файл-линк на питон в вашем виртуальном окружении
И запускайте
Ivan Yakushenko, я так и делал. С pyowm разобрался, заработало. Но с pip install pyTelegramBotAPI такая же проблема, не устанавливает
equirement already satisfied: pyTelegramBotAPI in c:\users\ave\appdata\local\programs\python\python37-32\lib\site-packages (3.6.6)