无法在 Windows 中安装 Pillow

Can't install Pillow in Windows

安装过程需要 zlib,我什至从 Github 安装并克隆了它。我是新手。

错误信息:

C:\Users\GThell\Pillow>pip install -e .
Obtaining file:///C:/Users/GThell/Pillow
Requirement already satisfied: olefile in c:\users\gthell\appdata\local\programs\python\python36\lib\site-packages (from Pillow==3.5.0.dev0)
Installing collected packages: Pillow
  Running setup.py develop for Pillow
    Complete output from command c:\users\gthell\appdata\local\programs\python\python36\python.exe -c "import setuptools, tokenize;__file__='C:\Users\GThell\Pillow\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" develop --no-deps:
    Single threaded build for windows
    running develop
    running egg_info
    writing Pillow.egg-info\PKG-INFO
    writing dependency_links to Pillow.egg-info\dependency_links.txt
    writing requirements to Pillow.egg-info\requires.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 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 'tox.ini'
    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'
    running build_ext


    The headers or library files could not be found for zlib,
    a required dependency when compiling Pillow from source.

    Please see the install instructions at:
       http://pillow.readthedocs.io/en/latest/installation.html

    Traceback (most recent call last):
      File "C:\Users\GThell\Pillow\setup.py", line 778, in <module>
        zip_safe=not debug_build(), )
      File "c:\users\gthell\appdata\local\programs\python\python36\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "c:\users\gthell\appdata\local\programs\python\python36\lib\distutils\dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "c:\users\gthell\appdata\local\programs\python\python36\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "c:\users\gthell\appdata\local\programs\python\python36\lib\site-packages\setuptools\command\develop.py", line 34, in run
        self.install_for_development()
      File "c:\users\gthell\appdata\local\programs\python\python36\lib\site-packages\setuptools\command\develop.py", line 119, in install_for_development
        self.run_command('build_ext')
      File "c:\users\gthell\appdata\local\programs\python\python36\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\users\gthell\appdata\local\programs\python\python36\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "c:\users\gthell\appdata\local\programs\python\python36\lib\distutils\command\build_ext.py", line 339, in run
        self.build_extensions()
      File "C:\Users\GThell\Pillow\setup.py", line 549, in build_extensions
        raise RequiredDependencyException(f)
    __main__.RequiredDependencyException: zlib

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\GThell\Pillow\setup.py", line 790, in <module>
        raise RequiredDependencyException(msg)
    __main__.RequiredDependencyException:

    The headers or library files could not be found for zlib,
    a required dependency when compiling Pillow from source.

    Please see the install instructions at:
       http://pillow.readthedocs.io/en/latest/installation.html

错误消息底部的 URL 表示:

Windows Installation We provide Pillow binaries for Windows compiled for the matrix of supported Pythons in both 32 and 64-bit versions in wheel, egg, and executable installers. These binaries have all of the optional libraries included:

pip install Pillow

我会尝试这样做,以避免依赖性问题,例如您 运行 遇到的问题。

编辑:pillow 只支持 Pillow >= 2.0.0 < 3.5.0 不支持 3.6.0

编辑:希望这项工作可行,我无法在 Windows 上进行实际测试。

在 Windows,你最好使用预编译的二进制文件(轮子)而不是从源代码构建。

Python 3.6.0 最终版将于本周晚些时候在 2016-12-23 发布,Pillow 尚不支持它。希望它能在 2017 年 1 月 1 日的下一个季度版本中得到支持。

不过,与此同时,您可以从这里下载一个非官方的 wheel,然后 pip install filename.whl

http://www.lfd.uci.edu/~gohlke/pythonlibs/#pillow

使用:

easy_install pillow

pip 无法正常工作

我最近在 Cygwin 的 Python3.6 下安装了 Pillow 并且需要以下软件包:

  • gcc-core
  • libjpeg-devel
  • zlib-devel
  • python3-devel
  • python3-setuptools(到运行easy-install-3.6

我还安装了 pip 使用:

easy-install-3.6 install pip

然后最后:

pip3 install pillow

成功。

您可以尝试使用其 Windows 安装程序包安装 Pillow。
检查 https://pypi.org/project/Pillow/#files、Windows 安装程序包位于页面底部。
为我工作 Python 3.7.

在 windows 中,由于框架问题,一些软件包无法运行。同样可以通过 3rd 方站点下载和使用它。

Unofficial python Binaries

选择相应的版本下载相同的

然后例如,

pip install Downloads\Pillow.whl

现在安装不会出错

根据 docs:

python3 -m pip install --upgrade pip
python3 -m pip install --upgrade Pillow

您可能需要将 python3 替换为 pypy3python,具体取决于您的安装。

使用普通的旧 pip install Pillow 对我不起作用,easy_install Pillow 也不起作用,它抱怨说 EasyInstall 无法安全地安装它。

pip install wheel
pip install Pillow

为我工作