No Module named PIL

前端 未结 7 1672
小蘑菇
小蘑菇 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 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
    
    

提交回复
热议问题