No Module named PIL

前端 未结 7 1536
小蘑菇
小蘑菇 2021-02-01 03:51

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

相关标签:
7条回答
  • 2021-02-01 03:54

    This solution is for pip version 20 and using PyCharm. I'd upgrade pip to version 20.0.2 as pip suggested but I had to get back to version 19

    python -m pip install pip==19.3.1
    

    I also installed Pillow from command line

    pip install Pillow
    

    And finally installed Pillow inside PyCharm on Settings -> Project:your-project-name -> Project Interpreter, clicked on + button and installed Pillow.

    0 讨论(0)
  • 2021-02-01 04:01

    For me, when I was trying to use PIL in PyCharm, initially the Project Interpreter was not looking at the correct location for Python 3.7. This has been corrected and using PIL works for me now (corrected Interpreter shown in image attached).

    0 讨论(0)
  • 2021-02-01 04:03

    You can use python -m pip install Pillow or pip install Pillow

    0 讨论(0)
  • 2021-02-01 04:11

    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:

    pip install --upgrade pip
    

    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:

    Python 2.7.12 (default, Jun 29 2016, 13:16:51)
    [GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import PIL
    >>> from PIL import Image
    >>> Image
    <module 'PIL.Image' from '/usr/local/lib/python2.7/site-packages/PIL/Image.pyc'>
    
    0 讨论(0)
  • 2021-02-01 04:15

    In my case, on Windows, all I needed to do is to run:

    pip install pillow

    0 讨论(0)
  • 2021-02-01 04:15

    OSX

    sudo easy_install pip
    pip install Pillow --user
    
    0 讨论(0)
提交回复
热议问题