如何为Python 3.6安装PIL / Pillow?

问题描述 投票:41回答:3

我有一个需要PIL运行的脚本。除了降级我的Python,我无论如何都找不到在我的Python 3.6上安装PIL

以下是我的尝试:

pip install pil
Collecting pil
  Could not find a version that satisfies the requirement pil (from versions: )
No matching distribution found for pil

pip install Pillow
Collecting Pillow
  Using cached Pillow-3.3.1.zip
Installing collected packages: Pillow
  Running setup.py install for Pillow ... error
    Complete output from command c:\python\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\ABDULR~1\\AppData\\Local\\Temp\\pip-build-rez5zpri\\Pillow\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\ABDULR~1\AppData\Local\Temp\pip-a5bugnjo-record\install-record.txt --single-version-externally-managed --compile:
    Single threaded build for windows
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.6
    creating build\lib.win-amd64-3.6\PIL
    copying PIL\......................
    ..................................
    ..................................
    running egg_info
    writing Pillow.egg-info\PKG-INFO
    writing dependency_links to Pillow.egg-info\dependency_links.txt
    writing top-level names to Pillow.egg-info\top_level.txt
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'Pillow.egg-info\SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching '*.sh'
    no previously-included directories found matching 'docs\_static'
    warning: no previously-included files found matching '.coveragerc'
    warning: no previously-included files found matching '.editorconfig'
    warning: no previously-included files found matching '.landscape.yaml'
    warning: no previously-included files found matching 'appveyor.yml'
    warning: no previously-included files found matching 'build_children.sh'
    warning: no previously-included files found matching 'tox.ini'
    warning: no previously-included files matching '.git*' found anywhere in distribution
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    warning: no previously-included files matching '*.so' found anywhere in distribution
    writing manifest file 'Pillow.egg-info\SOURCES.txt'
    copying PIL\OleFileIO-README.md -> build\lib.win-amd64-3.6\PIL
    running build_ext
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\ABDULR~1\AppData\Local\Temp\pip-build-rez5zpri\Pillow\setup.py", line 753, in <module>
        zip_safe=not debug_build(), )
      File "c:\python\python36\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "c:\python\python36\lib\distutils\dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "c:\python\python36\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "c:\python\python36\lib\site-packages\setuptools\command\install.py", line 61, in run
        return orig.install.run(self)
      File "c:\python\python36\lib\distutils\command\install.py", line 539, in run
        self.run_command('build')
      File "c:\python\python36\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\python\python36\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "c:\python\python36\lib\distutils\command\build.py", line 135, in run
        self.run_command(cmd_name)
      File "c:\python\python36\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\python\python36\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "c:\python\python36\lib\distutils\command\build_ext.py", line 338, in run
        self.build_extensions()
      File "C:\Users\ABDULR~1\AppData\Local\Temp\pip-build-rez5zpri\Pillow\setup.py", line 521, in build_extensions
        ' using --disable-%s, aborting' % (f, f))
    ValueError: zlib is required unless explicitly disabled using --disable-zlib, aborting

    ----------------------------------------
Command "c:\python\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\ABDULR~1\\AppData\\Local\\Temp\\pip-build-rez5zpri\\Pillow\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\ABDULR~1\AppData\Local\Temp\pip-a5bugnjo-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\ABDULR~1\AppData\Local\Temp\pip-build-rez5zpri\Pillow\

不知道添加参数--disable-zlibpip install Pillow --disable-zlib不正确。

找不到符合我系统的内容:https://pypi.python.org/pypi/Pillow/3.0.0

64位Windows 10和Python 3.6

python-3.x python-imaging-library pillow
3个回答
52
投票

对于python版本2.x,您可以简单地使用

  • pip install pillow

但对于python版本3.X,您需要指定

  • (sudo) pip3 install pillow

当你在bash hit标签中输入pip时,你会看到你有什么选择


4
投票

您可以下载与您的配置here相对应的滚轮(在您的情况下为“Pillow-4.1.1-cp36-cp36m-win_amd64.whl”)并安装它:

pip install some-package.whl

如果你有问题安装车轮阅读this answer


1
投票

在Windows上发布带有安装轮的枕头:

我们提供了Windows的Pillow二进制文件,这些二进制文件是为支持的Pythons矩阵编译的,包括32位和64位版本的wheel,egg和可执行安装程序。这些二进制文件包含所有可选库

https://pillow.readthedocs.io/en/3.3.x/installation.html#basic-installation

更新:Pillow现在支持Python 3.6。使用pip install pillow安装并检查https://pillow.readthedocs.io/en/latest/installation.html以获取更多信息。


但是,Python 3.6仍然处于alpha状态,尚未得到官方支持,尽管测试确实都通过了夜间Python构建(目前为3.6a4)。

https://travis-ci.org/python-pillow/Pillow/jobs/155605577

如果以某种方式可以安装3.5转3.6,这是你最好的选择。否则,zlib尽管如此,你需要从源代码构建,需要一个MS Visual C ++编译器,这并不简单。有关提示,请参阅

https://pillow.readthedocs.io/en/3.3.x/installation.html#building-from-source

还可以看看它是如何在AppVeyor CI上构建的(但还不是3.5或3.6):

https://github.com/python-pillow/Pillow/tree/master/winbuild

如果做不到这一点,Pillow支持降级到Python 3.5或等到3.6,可能更接近3.6的正式版本。

© www.soinside.com 2019 - 2024. All rights reserved.