Why can't Python import Image from PIL?

后端 未结 17 1811
执念已碎
执念已碎 2020-12-03 06:49

The single line that I am trying to run is the following:

from PIL import Image

However simple this may seem, it gives an error:

         


        
相关标签:
17条回答
  • 2020-12-03 07:16

    The current free version is PIL 1.1.7. This release supports Python 1.5.2 and newer, including 2.5 and 2.6. A version for 3.X will be released later.

    Python Imaging Library (PIL)

    Your python version is 3.4.1, PIL do not support!

    0 讨论(0)
  • 2020-12-03 07:16

    Try import PIL instead of from PIL import image.

    0 讨论(0)
  • 2020-12-03 07:17

    I had the same problem, pillow was installed with an environment.yml in anaconda

    I am quickly learning that pip and setuptools must always be up to date or I will have problems. Always update these tools before installing packages.For any package import problem uninstall the package upgrade the listed tools(maybe even your base environment) and reinstall.

    conda uninstall pillow
    python -m pip install pip --upgrade
    pip install setuptools --upgrade
    pip install pillow
    

    If using Anaconda, from the base environment first run the following before installing packages/environments:

    conda update conda
    

    Updating the base env is not required to fix this issue but is a good practice to avoid similar problems

    @theeastcoastwest touched on the pip upgrade in their answer but I felt more information was needed

    0 讨论(0)
  • 2020-12-03 07:20

    do from PIL import Image, ImageTk

    0 讨论(0)
  • 2020-12-03 07:21

    In Ubuntu OS, I solved it with the followings commands

    pip install Pillow
    apt-get install python-imaging
    

    And sorry, dont ask me why, it's up to me ;-)

    0 讨论(0)
提交回复
热议问题