why can't I use pillow when I have pillow? [duplicate] - python

This question already has answers here:
Package (Python PIL/Pillow) installed but I can't import it
(3 answers)
Closed last year.
E:\python>pyota.py
Traceback (most recent call last):
File "E:\python\pyota.py", line 6, in <module>
import PILLOW
ModuleNotFoundError: No module named 'PILLOW'
E:\python>pip install pillow
Requirement already satisfied: pillow in c:\users\admin\appdata\local\programs\python\python310\lib\site-packages (9.0.0)
Even if I used 'pillow' it didn't work:
Traceback (most recent call last):
File "E:\python\pyota.py", line 6, in <module>
import pillow
ModuleNotFoundError: No module named 'pillow'

The download module is called "pillow", but the import is PIL (Python Imaging Library). Pillow was forked from PIL as a clone, and was improved so much that it has replaced it.
from PIL import Image
or
import PIL

Related

Python loading wrong Pillow (PIL) package

I have strange issue while loading matplotlib package. Never observed that before. The package is trying to load PIL from the wrong place. If I try to load PIL from the command line, it also loaded from the wrong place.
Here is matplotlib traceback:
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/XXX/python_rep/miniconda3/envs/work/lib/python3.9/site-packages/matplotlib/__init__.py", line 113, in <module>
from . import _api, _version, cbook, _docstring, rcsetup
File "/home/XXX/python_rep/miniconda3/envs/work/lib/python3.9/site-packages/matplotlib/rcsetup.py", line 27, in <module>
from matplotlib.colors import Colormap, is_color_like
File "/home/XXX/python_rep/miniconda3/envs/work/lib/python3.9/site-packages/matplotlib/colors.py", line 51, in <module>
from PIL import Image
File "/homeappl/common-software/sw/python3.6/lib/python3.6/site-packages/PIL/Image.py", line 69, in <module>
from . import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL' (/homeappl/common-software/sw/python3.6/lib/python3.6/site-packages/PIL/__init__.py)
Please note that I use my own conda environment with python 3.9
It is activated and contained Pillow version 9.0.0
Other packages are loaded from that instance, but bloody PIL tries to reach the common area.
/home/XXX/python_rep/miniconda3/envs/work/bin/python3.9 -m pip install pillow
Requirement already satisfied: pillow in /homeappl/common-software/sw/python3.6/lib/python3.6/site-packages (7.0.0)
I have no idea why it tries to load package from old place. But I do not have access to that - due to admin rights.
How to force machine not to use wrong package?

no module named numpy despite numpy being already installed

i get this error when running a python script
Traceback (most recent call last):
File "C:\Users\BruceWayne\Desktop\TF\train.py", line 2, in <module>
import numpy
ImportError: No module named numpy
So i tried
pip install numpy
and the answer was that the requirement is already satisfied

No module named SpeechRecognition

I am using the python 2.7.13 shell, as you can see in the code below, I have installed speechrecognition, but it isn't showing up.
>>> pip.main (['install','speechrecognition'])
Requirement already satisfied: speechrecognition in
c:\python27\lib\site-packages
0
>>> import speechrecognition
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
import speechrecognition
ImportError: No module named speechrecognition
>>>
Try
import speech_recognition
Note the underscore

Error importing Images from PIL: The _imaging extension was built for another version of Pillow or PIL

I want to work with images in python, but I get an error when I try to use PIL. I want to import images from PIL with the following command:
from PIL import Image
But I get the following error:
Traceback (most recent call last):
File "<pyshell#15>", line 1, in <module>
from PIL import Image
File "C:\Users\User\AppData\Local\Programs\Python\Python36-32\lib\site-packages\PIL\Image.py", line 56, in <module>
from . import _imaging as core
ImportError: DLL load failed: A megadott eljárás nem található.
(The last sentence translates to 'The specified procedure could not be found')
I followed the instructions under this question and uninstalled Pillow 4.1.0 and reinstalled Pillow 4.0.0. It didn't solve my problem, but now I get a different error message:
Warning (from warnings module):
File "C:\Users\User\AppData\Local\Programs\Python\Python36-32\lib\site-packages\PIL\Image.py", line 74
# Explanations for ways that we know we might have an import error
RuntimeWarning: The _imaging extension was built for another version of Pillow or PIL
Traceback (most recent call last):
File "<pyshell#19>", line 1, in <module>
from PIL import Image
File "C:\Users\User\AppData\Local\Programs\Python\Python36-32\lib\site-packages\PIL\Image.py", line 58, in <module>
raise ImportError("The _imaging extension was built for another "
ImportError: The _imaging extension was built for another version of Pillow or PIL
Following the instructions on another question I uninstalled PIL (but failed because it wasn't installed in the first place), then uninstalled pillow, and then reinstalled pillow (the newest version), but I still get the second error message.
I am using windows 8.1 and python 3.6.0. Does anybody know how to solve this problem?

Error using Pillow: ImportError: cannot import name _imaging

I've read the answers for similar questions but none of them seem to work for my situation.
When trying to use Pillow, I get this error:
>>> from PIL import Image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/PIL/Image.py", line 63, in <module>
from PIL import _imaging as core
ImportError: cannot import name _imaging
In my /Library/Python/2.7/site-packages directory I have one PIL directory which contains the Image module and then I have PIllow-master directory which contains _imaging.c, so I don't understand why in Image.py line 63 says to import _imaging from PIL.
I've tried also to cut _imaging.c from Pillow-master and paste it in PIL but it doesn't work.
When trying to import Image, I'm into PIL.
If I try to import it while I'm into site-packages it doesn't work and says "no module named PIL".
Try to remove your PIL library and install new by:
pip install PIL --allow-external PIL --allow-unverified PIL

Categories