无法在Windows上的Python 3.7.0a上安装Pillow

时间:2018-03-28 11:59:57

标签: python django pillow python-3.7

我在Windows 10中使用Python 3.7.0a2和Django(2,0,2,' final',0)。 当我正在迁移我的项目时,我收到以下错误:

ERRORS:
accounts.UserProfile.image: (fields.E210) Cannot use ImageField because Pillow is not installed.
        HINT: Get Pillow at https://pypi.python.org/pypi/Pillow or run command "pip install Pillow".

然后我运行了'pip install Pillow'命令,我收到以下错误:

  Traceback (most recent call last):
    File "C:\Users\VIKASV~1\AppData\Local\Temp\pip-build-hfzb5tde\pillow\setup.py", line 792, in <module>
      zip_safe=not (debug_build() or PLATFORM_MINGW), )
    File "c:\users\vikas visking\appdata\local\programs\python\python37\lib\distutils\core.py", line 148, in setup
      dist.run_commands()
    File "c:\users\vikas visking\appdata\local\programs\python\python37\lib\distutils\dist.py", line 955, in run_commands
      self.run_command(cmd)
    File "c:\users\vikas visking\appdata\local\programs\python\python37\lib\distutils\dist.py", line 974, in run_command
      cmd_obj.run()
    File "c:\users\vikas visking\appdata\local\programs\python\python37\lib\site-packages\setuptools\command\install.py", line 61, in run
      return orig.install.run(self)
    File "c:\users\vikas visking\appdata\local\programs\python\python37\lib\distutils\command\install.py", line 545, in run
      self.run_command('build')
    File "c:\users\vikas visking\appdata\local\programs\python\python37\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "c:\users\vikas visking\appdata\local\programs\python\python37\lib\distutils\dist.py", line 974, in run_command
      cmd_obj.run()
    File "c:\users\vikas visking\appdata\local\programs\python\python37\lib\distutils\command\build.py", line 135, in run
      self.run_command(cmd_name)
    File "c:\users\vikas visking\appdata\local\programs\python\python37\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "c:\users\vikas visking\appdata\local\programs\python\python37\lib\distutils\dist.py", line 974, in run_command
      cmd_obj.run()
    File "c:\users\vikas visking\appdata\local\programs\python\python37\lib\distutils\command\build_ext.py", line 339, in run
      self.build_extensions()
    File "C:\Users\VIKASV~1\AppData\Local\Temp\pip-build-hfzb5tde\pillow\setup.py", line 580, 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\VIKASV~1\AppData\Local\Temp\pip-build-hfzb5tde\pillow\setup.py", line 804, 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:
     https://pillow.readthedocs.io/en/latest/installation.html

如何安装枕头?

5 个答案:

答案 0 :(得分:1)

枕头需要在Windows上编译。 #include <iostream> #include <iomanip> int main() { std::cout << std::setw(15) << std::setfill('-') << "PRODUCT" << std::setw(15) << std::setfill('-') << "AMOUNT" << std::endl; std::cout << std::setw(15) << std::setfill('-') << "Brush" << std::setw(15) << std::setfill('-') << 10 << std::endl; std::cout << std::setw(15) << std::setfill('-') << "Paste" << std::setw(15) << std::setfill('-') << 8 << std::endl << std::endl; std::cout << std::setw(15) << std::left << std::setfill('-') << "PRODUCT" << std::setw(15) << std::left << std::setfill('-') << "AMOUNT" << std::endl; std::cout << std::setw(15) << std::left << std::setfill('-') << "Brush" << std::setw(15) << std::left << std::setfill('-') << 10 << std::endl; std::cout << std::setw(15) << std::left << std::setfill('-') << "Paste" << std::setw(15) << std::left << std::setfill('-') << 8 << std::endl << std::endl; std::cout << std::setw(15) << std::right << std::setfill('-') << "PRODUCT" << std::setw(15) << std::right << std::setfill('-') << "AMOUNT" << std::endl; std::cout << std::setw(15) << std::right << std::setfill('-') << "Brush" << std::setw(15) << std::right << std::setfill('-') << 10 << std::endl; std::cout << std::setw(15) << std::right << std::setfill('-') << "Paste" << std::setw(15) << std::right << std::setfill('-') << 8 << std::endl << std::endl; return 0; } 尝试使用预编译版本,如果失败 - 它会尝试在本地编译它。

你正在使用尚未发布的Python 3.7,我怀疑枕头人没有准备好预编译的二进制文件。

最简单的解决方案是降级到Python 3.6。否则,您需要安装编译Pillow所需的一切。

答案 1 :(得分:1)

here提供了用于python 3.7的Pillow的预编译版本。

在下载的车轮上运行pip install对我来说很有效。

答案 2 :(得分:0)

尝试像下面一样安装Pillow(如果您使用的是Python3):

pip3 install pillow

这个:(如果您使用的是Python2):

pip install pillow

答案 3 :(得分:0)

对于带有python3.7的最新Anaconda,可提供枕头。使用以下命令安装它:

conda install pillow

然后,停用当前的环境,然后再次激活环境,它应该可以工作。 (此步骤对于使其有效很重要)

答案 4 :(得分:0)

也许有人会有用。

只有将某些软件包更新为某些版本后,我才能在虚拟环境中安装软件包 Pillow 7.0.0)。

我将软件包setuptools更新到了最新版本(当时是44.0.0

并将软件包pip更新为19.2.3


作为参考,我使用了: Python 3.8.0, Django 2.2.8, Virtualenv 16.7.9, Windows 10 SL x64