From pil import image не работает

Содержание
  1. Почему Python не может импортировать изображение из PIL?
  2. 9 ответов
  3. ImportError: cannot import name ‘_imaging’ from ‘PIL’ #4416
  4. Comments
  5. Coolgamerguy4793 commented Feb 11, 2020 •
  6. What did you do?
  7. What did you expect to happen?
  8. What actually happened?
  9. What are your OS, Python and Pillow versions?
  10. radarhere commented Feb 14, 2020
  11. Coolgamerguy4793 commented Feb 14, 2020 •
  12. radarhere commented Feb 14, 2020
  13. radarhere commented Feb 20, 2020
  14. radarhere commented Feb 26, 2020
  15. HTG-YT commented Feb 29, 2020
  16. radarhere commented Feb 29, 2020
  17. HTG-YT commented Feb 29, 2020 •
  18. HTG-YT commented Feb 29, 2020
  19. HTG-YT commented Feb 29, 2020
  20. radarhere commented Feb 29, 2020
  21. HTG-YT commented Feb 29, 2020
  22. HTG-YT commented Feb 29, 2020
  23. shiba24 commented Apr 6, 2020
  24. radarhere commented Apr 21, 2020
  25. HTG-YT commented May 12, 2020
  26. Linkontoask commented Jun 29, 2020
  27. padfoot-y2m commented Aug 28, 2020
  28. radarhere commented Aug 28, 2020
  29. etasnadi commented Dec 2, 2020
  30. richtong commented Feb 4, 2021
  31. radarhere commented Feb 4, 2021
  32. ivanstepanovftw commented Sep 4, 2021
  33. radarhere commented Sep 4, 2021
  34. ImportError: No module named PIL
  35. 25 Answers 25
  36. cannot import name ‘_imaging’ from ‘PIL’ #3342
  37. Comments
  38. RichardAntalik commented Sep 8, 2018
  39. What did you do?
  40. What did you expect to happen?
  41. What actually happened?
  42. What versions of Pillow and Python are you using?
  43. radarhere commented Sep 9, 2018
  44. OHRjo commented Sep 9, 2018 •
  45. radarhere commented Sep 9, 2018
  46. hugovk commented Sep 9, 2018 •
  47. RichardAntalik commented Sep 9, 2018

Почему Python не может импортировать изображение из PIL?

Единственная строка, которую я пытаюсь запустить, следующая:

Каким бы простым это ни казалось, оно выдает ошибку:

В случае, если это будет полезно, я установил подушку с https://pypi.python.org/pypi/Pillow/2.6.1 (файл Pillow-2.6.1.win-amd64-py3.4.exe ) перед запуском этого (до этого уже был сом PIL установить, которую я удалил). Сценарий запускается в Pyzo с Python версии 3.4.1.

Что не так, как я могу импортировать Image ?

9 ответов

У меня была такая же ошибка. Здесь был мой рабочий процесс. Сначала я установил PIL (не подушку), используя

Затем я нашел подушку и установил ее с помощью

Что исправило мои проблемы, так это удаление и повторная установка подушки

Если вы используете Anaconda , вы можете попробовать:

Текущая бесплатная версия — PIL 1.1.7. Этот выпуск поддерживает Python 1.5.2 и новее, включая 2.5 и 2.6. Версия для 3.X будет выпущена позже.

Ваша версия на python 3.4.1, PIL не поддерживает!

У меня была та же проблема, и я сделал это, чтобы ее исправить:

В командной строке

Убедитесь, что вы используете

I в Image должен быть столицей. Это была проблема в моем случае.

В Ubuntu OS я решил это с помощью следующих команд

И извините, не спрашивайте меня, почему, это до меня; -)

Все ответы были великолепны, однако для меня это была комбинация удаления подушки

Затем установите все необходимые вам пакеты, например.

А затем с помощью easy_install переустановите подушку

Источник

ImportError: cannot import name ‘_imaging’ from ‘PIL’ #4416

Comments

Coolgamerguy4793 commented Feb 11, 2020 •

What did you do?

Tried to run: from PIL import Image

What did you expect to happen?

To get access to the Image package contained in PIL

What actually happened?

I got the error:

What are your OS, Python and Pillow versions?

  • OS: Windows 10
  • Python: 3.8.1
  • Pillow: 7.0.0

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

radarhere commented Feb 14, 2020

How did you install Pillow?

Coolgamerguy4793 commented Feb 14, 2020 •

I installed it from pip

radarhere commented Feb 14, 2020

Did you run pip install Pillow , or are you saying that you ran pip install PIL ? If you ran pip install PIL , then you should know that PIL does not support Python 3, so that will not ultimately work for you.

Читайте также:  Как починить разъем для кабеля

I presume you did not try and build Pillow from source.

Could you post the output of the following code?

radarhere commented Feb 20, 2020

Also, be aware of the documented instructions for installing Pillow using pip — https://pillow.readthedocs.io/en/latest/installation.html#windows-installation

radarhere commented Feb 26, 2020

Googling, I found suggestions that you might have PIL installed alongside Pillow. Could you try uninstalling Pillow, checking that you can no longer import PIL , and then re-installing Pillow?

I presume that you haven’t created a script named PIL.py that could be interfering.

HTG-YT commented Feb 29, 2020

Having the same issue here, however I am pretty sure that they aren’t installed side by side, with proof here:

radarhere commented Feb 29, 2020

@HTG-YT what operating system are you using? How did you install Pillow?

Could you post the output of the following code?

HTG-YT commented Feb 29, 2020 •

My operating system is Windows 10 Home.

The output of the code is as below:

@radarhere and I got that via pip install Pillow

HTG-YT commented Feb 29, 2020

and this is the traceback:

HTG-YT commented Feb 29, 2020

So with the traceback I wonder if it is a problem of the PIL package.

radarhere commented Feb 29, 2020

#4149 may be of interest to you

HTG-YT commented Feb 29, 2020

That doesn’t seem to work in the built-in terminal of PyCharm

HTG-YT commented Feb 29, 2020

Did that miniconda3 mean I have to install external stuff to my computer?

shiba24 commented Apr 6, 2020

I am getting the same error. I’m using virtual env — how is it resolved without miniconda?

radarhere commented Apr 21, 2020

I don’t want to suggest that you have to use miniconda, I’m just attempting to provide another situation in the hope that it will help and lead you towards a solution. https://stackoverflow.com/questions/55419368/in-pycharm-importerror-dll-load-failed-the-specified-module-could-not-be-found, for example, is a person who has a similar problem to this, with Anaconda, and resolves it by adding the interpreter to PyCharm. So maybe the interpreter settings could be a solution here?

HTG-YT commented May 12, 2020

Well after I updated to newer version so pip, the problem is resolved.

Linkontoask commented Jun 29, 2020

@HTG-YT I would like to know in which environment the problem was solved. I also tried to use the built code in the project.

  • Python: 3.7.3
  • Pillow: 5.2.0 (7.1.2 have tried)

padfoot-y2m commented Aug 28, 2020

I am using pycharm and I installed pillow from the settings,the version in 7.2.0. I am facing the same problem and after i type import PIL
print(PIL) i get this:
I am new in programming,please help me solve this issue.

radarhere commented Aug 28, 2020

The solution for @HTG-YT was to upgrade pip, so you might try

etasnadi commented Dec 2, 2020

Same issue here: ImportError: cannot import name ‘_imaging’ from ‘PIL’ (/usr/lib/python3/dist-packages/PIL/__init__.py) when using scikit-image (Pillow 7.0). Upgraded to 8.0.1 and it works.

richtong commented Feb 4, 2021

I’m getting this error on a Mac after running

This fails with the line

The Pillow version is 8.2

I also tried this with conda and with:

But when running this I get Pi

I get nearly the same error

So did something change with Pillow v8.1.0?

radarhere commented Feb 4, 2021

from PIL import images
from PIL import Images

For one thing, these are incorrect. It is from PIL import Image

ivanstepanovftw commented Sep 4, 2021

PyPy3 enjoyer is here.
Environment: Windows 10 x64 under VMWare Player. Installation was:

radarhere commented Sep 4, 2021

Did you want to try

  • uninstalling Pillow
  • check that you can’t import it at all, to confirm that you don’t have more than one copy installed
  • and then

Источник

ImportError: No module named PIL

I use this command in the shell to install PIL:

Читайте также:  Как настроить пульт самсунг для приставки ростелеком

then I run python and type this: import PIL . But I get this error:

I’ve never had such problem, what do you think?

25 Answers 25

Attention: PIL is deprecated, and pillow is the successor.

On some installs of PIL, you must do

instead of import PIL (PIL is in fact not always imported this way). Since import Image works for you, this means that you have in fact installed PIL.

Having a different name for the library and the Python module is unusual, but this is what was chosen for (some versions of) PIL.

You can get more information about how to use this module from the official tutorial.

PS: In fact, on some installs, import PIL does work, which adds to the confusion. This is confirmed by an example from the documentation, as @JanneKarila found out, and also by some more recent versions of the MacPorts PIL package (1.1.7).

On a different note, I can highly recommend the use of Pillow which is backwards compatible with PIL and is better maintained/will work on newer systems.

When that is installed you can do

At first install Pillow with

Then in python code you may call

«Pillow is a fork of PIL, the Python Imaging Library, which is no longer maintained. However, to maintain backwards compatibility, the old module name is used.» From pillow installed, but «no module named pillow» — python2.7 — Windows 7 — python -m install pillow

Sometimes I get this type of error running a Unitest in python. The solution is to uninstall and install the same package on your virtual environment.

Using this commands:

If for any reason you get an error, add sudo at the beginning of the command and after hitting enter type your password.

This worked for me on Ubuntu 16.04:

I found this on Wikibooks after searching for about half an hour.

you have to install Image and pillow with your python package.

or run command prompt (in windows), then navigate to the scripts folder

then run below command

On windows 10 I managed to get there with:

after which in python (python 3.7 in my case) this works fine.

and pip installed PIL in Lib\site-packages. When I moved PIL to Lib everything worked fine. I’m on Windows 10.

if you use anaconda:

On windows, try checking the path to the location of the PIL library. On my system, I noticed the path was

after renaming the pil folder to PIL , I was able to load the PIL module.

instead of PIL use Pillow it works

You will need to install Image and pillow with your python package. Rest assured, the command line will take care of everything for you.

python -m pip install image

Install Specific Version:

Getting Dependency Error in Window 10 Use code: easy_install instead of pip install

Upgrade using easy install

On OSX System to install Module: Use code: brew install instead of pip install

Without Using Pip :

On CentOS7 or Linux Fedora:

Or on Fedora try

Command if Homebrew screws up your path on macOS:

For Python3 MacOs Homebrew screws

Verify module from list MacOs

For Execute on Anaconda as your python package manager

On Windows, you need to download it and install the .exe

I used conda-forge to install pillow version 5, and that seemed to work for me:

the normal conda install pillow did NOT work for me.

and it worked for me fine

use pil instead of PIL

I had the same issue while importing PIL and further importing the ImageTk and Image modules. I also tried installing PIL directly through pip. but not success could be achieved. As in between it has been suggested that PIL has been deprectaed, thus, tried to install pillow through pip only. pillow was successfully installed, further, the PIL package was made under the path : python27/Lib/site-packages/.

Читайте также:  Как настроить трансляцию стима

Now both Image and ImageTk could be imported.

I recently installed Leap. I Tried openshot and it didn’t start. So came here and found a suggestion to start from the Terminal to see if there were any error.

The error I had was error missing mlt . So I installed the python-mlt module from Yast and imported it, tried to start but next openshot said missing pil.

I Followed the Pillow suggestion to install because Yast couldn’t find any pil and imported pil. That went ok but did not start and showed Error missing goocanvas .

The I installed goocanvas with Yast, imported it in python, and Openshot fired up !!

With a lot of errors in the terminal like missing Vimeoclient and lots of attributeerrors . Well, will see if it is of any influence working with it.

Источник

cannot import name ‘_imaging’ from ‘PIL’ #3342

Comments

RichardAntalik commented Sep 8, 2018

What did you do?

import pillow Image module from within Blender

What did you expect to happen?

module to be imported

What actually happened?

Module did not import

What versions of Pillow and Python are you using?

python 3.7.0
pillow 5.2.0

When I run python console, I can use pillow without problems.
When I run (same) python console from within blender pillow will not load.
I tried this with numpy, and result is the same

From what I know, blender, python and pillow should be compiled using the «same» compiler. Normally with blender you build python and numpy and I can use them.
I am using MSVC 2017 runtime v140.

Is there a way to make this work without building pillow?

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

radarhere commented Sep 9, 2018

When you say ‘I tried this with numpy, and result is the same’, you mean that unrelated to Pillow, numpy will also not import for you within Blender, giving you a different error, yes? Would you be able to provide that error, in case there is a common element between both problems?

You say ‘Normally with blender you build python and numpy and I can use them’ — so what is the difference between this time and ‘normally’?

OHRjo commented Sep 9, 2018 •

I have the same problem here. I did «pip install wordcloud», wordcloud, pillow and numpy were installed together as a package.
Current installed:
python 3.6.4
wordcloud 1.5.0
pillow 5.2.0
numpy 1.14.2

I am getting an error:

ImportError: The _imaging extension was built for another version of Pillow or PIL:
Core version: 5.2.0
Pillow version: 5.0.0

Is it the PIL problem or the wordcloud problem?

radarhere commented Sep 9, 2018

@OHRjo you’re receiving a different error message, so that’s a different problem. The error is telling you that the compiled C code comes from one version of Pillow (5.2.0), while the Python code comes from another (5.0.0). I would recommend uninstalling and reinstalling Pillow.

hugovk commented Sep 9, 2018 •

@OHRjo If you’re using Conda, it’s a duplicate of #2945 (which also affected Wordcloud users on Windows). See #2945 (comment) for a workaround, or see conda/conda#7626 for a proposed Conda fix you can test.

RichardAntalik commented Sep 9, 2018

When you say ‘I tried this with numpy, and result is the same’, you mean that unrelated to Pillow, numpy will also not import for you within Blender, giving you a different error, yes?

Yes different error, not loading.

You say ‘Normally with blender you build python and numpy and I can use them’ — so what is the difference between this time and ‘normally’?

In blender I can select which python I want to use.
With built python, I can load built numpy, but not pillow. I tried import from command line, eliminating blender influence, still same issue.

I switched python to another one(installed with installer) I confirmed, that this is another python.
I could not load pillow or numpy.

Источник

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