I am trying to import the image module from pillow 5.1.0. Using python 3.6.5.
I typed in the following command
from PIL import image.
Upon doing this I get the following error.
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
from PIL import image
ImportError: cannot import name 'image'
Try from PIL import Image (note the capital 'I' in Image).
Related
Pillow has been added to the project. Here's the code:
from PIL import Image, ImageFilter, ImageDraw, ImageFont
im = Image.open("someImage.jpg")
print(im.width, im.height, im.mode, im.format) # Display
im.show(im)
Pillow is imported and the code runs fine, but PyDev gives the error:
Unresolved import: Image
――――――――――――――――――――
Image Found at: foo
from PIL import Image, ImageFilter, ImageDraw, ImageFont
If I comment out the import statement, I get a different error:
Traceback (most recent call last):
File "C:\ImagePractice\foo.py", line 2, in <module>
im = Image.open("someImage.jpg")
NameError: name 'Image' is not defined
#nicomp if you add PIL to the Forced Builtins in the interpreter you're using, does it work? (see: https://www.pydev.org/manual_101_interpreter.html for more details)
When trying to load an image file with scipy.misc.imread(), I receive this unexpected error:
Traceback (most recent call last):
File "/home/ghita/PycharmProjects/image_processing/venv/test1.py", line 2, in <module>
from scipy.misc import imread, imsave
ImportError: cannot import name 'imread' from 'scipy.misc' (/home/ghita/PycharmProjects/image_processing/venv/lib/python3.8/site-packages/scipy/misc/__init__.py)
Why does this fail?
It looks like imread has been removed from scipy.misc. They now recommend that you use imread from the imageio package.
I am having trouble with PIL import Image. I have Pillow installed. But when I try something like from PIL import Image it gives following error.
>>> from PIL import Image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/Pillow-2.5.2-py2.7-macosx-10.5-i386.egg/PIL/Image.py", line 61, in <module>
from PIL import _imaging as core
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/Pillow-2.5.2-py2.7-macosx-10.5-i386.egg/PIL/_imaging.so, 2): Symbol not found: _TIFFClientOpen
Referenced from: /Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/Pillow-2.5.2-py2.7-macosx-10.5-i386.egg/PIL/_imaging.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/Pillow-2.5.2-py2.7-macosx-10.5-i386.egg/PIL/_imaging.so
I have such code in the beginning of a file:
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
And it throws the error:
python3 main.pyTraceback (most recent call last):
File "main.py", line 1, in <module>
from PIL import Image
ImportError: No module named 'PIL'
According to many ad vices I should just replace import PIL with what I actually have. But is doesn't work as you can see.
It's on Ubuntu 14.04 and Python 3.4.0
According to this you should be able to do import Image instead of import PIL.
I have Pillow and qrcode modules installed in a virtual environment.
From the python shell, I can create a test image programmatically using PIL:
>>> from PIL import Image
>>> img = Image.new('1', (200, 200))
>>> img.save('test-image.jpeg', 'JPEG')
Great, that works just as I would expect it to. However, I'm getting this error when I try to use a module that relies on PIL:
>>> import qrcode
>>> qr_code = qrcode.make("1")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/vagrant/.virtualenvs/env1/local/lib/python2.7/site-packages/qrcode/main.py", line 8, in make
return qr.make_image()
File "/home/vagrant/.virtualenvs/env1/local/lib/python2.7/site-packages/qrcode/main.py", line 186, in make_image
from qrcode.image.pil import PilImage
File "/home/vagrant/.virtualenvs/env1/local/lib/python2.7/site-packages/qrcode/image/pil.py", line 5, in <module>
import Image
ImportError: No module named Image
Why can't qrcode import PIL's Image class but it works from the shell?
This is an issue with your installation: Image module have been installed as subpackage of a PIL module, while the library you are using expects Image module to be directly in the python path. Simplest solution is to replace:
import Image
with:
from PIL import Image
in file qrcode/image/pil.py.