4

我正在尝试PIL在 virtualenv 中安装但失败了。我创建了一个全新的 virtualenv 并做pip install PIL了并得到了以下

C:\Users\s3z\Desktop\My Dropbox\pythons\ham>Scripts\activate
(ham) C:\Users\s3z\Desktop\My Dropbox\pythons\ham>pip install PIL
Downloading/unpacking PIL
  Downloading PIL-1.1.7.tar.gz (506Kb): 506Kb downloaded
  Running setup.py egg_info for package PIL
    WARNING: '' not a valid package name; please use only.-separated package names in setup.py

Installing collected packages: PIL
  Running setup.py install for PIL
    WARNING: '' not a valid package name; please use only.-separated package names in setup.py
    building '_imaging' extension
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\s3z\Desktop\My Dropbox\pythons\ham\build\PIL\setup.py", line 486, in <module>
        version=VERSION,
      File "C:\Python27\Lib\distutils\core.py", line 152, in setup
        dist.run_commands()
      File "C:\Python27\Lib\distutils\dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "C:\Python27\Lib\distutils\dist.py", line 972, in run_command
        cmd_obj.run()
      File "C:\Users\s3z\Desktop\My Dropbox\pythons\ham\lib\site-packages\distribute-0.6.24-py2.7.egg\setuptools\command\install.py", line 53, in
run
        return _install.run(self)
      File "C:\Python27\Lib\distutils\command\install.py", line 563, in run
        self.run_command('build')
      File "C:\Python27\Lib\distutils\cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "C:\Python27\Lib\distutils\dist.py", line 972, in run_command
        cmd_obj.run()
      File "C:\Python27\Lib\distutils\command\build.py", line 127, in run
        self.run_command(cmd_name)
      File "C:\Python27\Lib\distutils\cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "C:\Python27\Lib\distutils\dist.py", line 972, in run_command
        cmd_obj.run()
      File "C:\Python27\Lib\distutils\command\build_ext.py", line 340, in run
        self.build_extensions()
      File "C:\Users\s3z\Desktop\My Dropbox\pythons\ham\build\PIL\setup.py", line 368, in build_extensions
        build_ext.build_extensions(self)
      File "C:\Python27\Lib\distutils\command\build_ext.py", line 449, in build_extensions
        self.build_extension(ext)
      File "C:\Python27\Lib\distutils\command\build_ext.py", line 499, in build_extension
        depends=ext.depends)
      File "C:\Python27\Lib\distutils\msvc9compiler.py", line 469, in compile
        self.initialize()
      File "C:\Python27\Lib\distutils\msvc9compiler.py", line 379, in initialize
        vc_env = query_vcvarsall(VERSION, plat_spec)
      File "C:\Python27\Lib\distutils\msvc9compiler.py", line 295, in query_vcvarsall
        raise ValueError(str(list(result.keys())))
    ValueError: [u'path']
    Complete output from command "C:\Users\s3z\Desktop\My Dropbox\pythons\ham\Scripts\python.exe" -c "import setuptools;__file__='C:\\Users\\s3z
\\Desktop\\My Dropbox\\pythons\\ham\\build\\PIL\\setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --s
ingle-version-externally-managed --record c:\users\s3z\appdata\local\temp\pip-f7ttlx-record\install-record.txt --install-headers "C:\Users\s3z
\Desktop\My Dropbox\pythons\ham\include\site\python2.7":
    WARNING: '' not a valid package name; please use only.-separated package names in setup.py

running install

running build

running build_py

creating build

creating build\lib.win-amd64-2.7

copying PIL\ArgImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\BdfFontFile.py -> build\lib.win-amd64-2.7

copying PIL\BmpImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\BufrStubImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\ContainerIO.py -> build\lib.win-amd64-2.7

copying PIL\CurImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\DcxImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\EpsImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\ExifTags.py -> build\lib.win-amd64-2.7

copying PIL\FitsStubImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\FliImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\FontFile.py -> build\lib.win-amd64-2.7

copying PIL\FpxImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\GbrImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\GdImageFile.py -> build\lib.win-amd64-2.7

copying PIL\GifImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\GimpGradientFile.py -> build\lib.win-amd64-2.7

copying PIL\GimpPaletteFile.py -> build\lib.win-amd64-2.7

copying PIL\GribStubImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\Hdf5StubImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\IcnsImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\IcoImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\Image.py -> build\lib.win-amd64-2.7

copying PIL\ImageChops.py -> build\lib.win-amd64-2.7

copying PIL\ImageCms.py -> build\lib.win-amd64-2.7

copying PIL\ImageColor.py -> build\lib.win-amd64-2.7

copying PIL\ImageDraw.py -> build\lib.win-amd64-2.7

copying PIL\ImageDraw2.py -> build\lib.win-amd64-2.7

copying PIL\ImageEnhance.py -> build\lib.win-amd64-2.7

copying PIL\ImageFile.py -> build\lib.win-amd64-2.7

copying PIL\ImageFileIO.py -> build\lib.win-amd64-2.7

copying PIL\ImageFilter.py -> build\lib.win-amd64-2.7

copying PIL\ImageFont.py -> build\lib.win-amd64-2.7

copying PIL\ImageGL.py -> build\lib.win-amd64-2.7

copying PIL\ImageGrab.py -> build\lib.win-amd64-2.7

copying PIL\ImageMath.py -> build\lib.win-amd64-2.7

copying PIL\ImageMode.py -> build\lib.win-amd64-2.7

copying PIL\ImageOps.py -> build\lib.win-amd64-2.7

copying PIL\ImagePalette.py -> build\lib.win-amd64-2.7

copying PIL\ImagePath.py -> build\lib.win-amd64-2.7

copying PIL\ImageQt.py -> build\lib.win-amd64-2.7

copying PIL\ImageSequence.py -> build\lib.win-amd64-2.7

copying PIL\ImageShow.py -> build\lib.win-amd64-2.7

copying PIL\ImageStat.py -> build\lib.win-amd64-2.7

copying PIL\ImageTk.py -> build\lib.win-amd64-2.7

copying PIL\ImageTransform.py -> build\lib.win-amd64-2.7

copying PIL\ImageWin.py -> build\lib.win-amd64-2.7

copying PIL\ImImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\ImtImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\IptcImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\JpegImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\McIdasImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\MicImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\MpegImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\MspImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\OleFileIO.py -> build\lib.win-amd64-2.7

copying PIL\PaletteFile.py -> build\lib.win-amd64-2.7

copying PIL\PalmImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\PcdImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\PcfFontFile.py -> build\lib.win-amd64-2.7

copying PIL\PcxImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\PdfImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\PixarImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\PngImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\PpmImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\PsdImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\PSDraw.py -> build\lib.win-amd64-2.7

copying PIL\SgiImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\SpiderImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\SunImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\TarIO.py -> build\lib.win-amd64-2.7

copying PIL\TgaImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\TiffImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\TiffTags.py -> build\lib.win-amd64-2.7

copying PIL\WalImageFile.py -> build\lib.win-amd64-2.7

copying PIL\WmfImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\XbmImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\XpmImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\XVThumbImagePlugin.py -> build\lib.win-amd64-2.7

copying PIL\__init__.py -> build\lib.win-amd64-2.7

running build_ext

building '_imaging' extension

Traceback (most recent call last):

  File "<string>", line 1, in <module>

  File "C:\Users\s3z\Desktop\My Dropbox\pythons\ham\build\PIL\setup.py", line 486, in <module>

    version=VERSION,

  File "C:\Python27\Lib\distutils\core.py", line 152, in setup

    dist.run_commands()

  File "C:\Python27\Lib\distutils\dist.py", line 953, in run_commands

    self.run_command(cmd)

  File "C:\Python27\Lib\distutils\dist.py", line 972, in run_command

    cmd_obj.run()

  File "C:\Users\s3z\Desktop\My Dropbox\pythons\ham\lib\site-packages\distribute-0.6.24-py2.7.egg\setuptools\command\install.py", line 53, in run

    return _install.run(self)

  File "C:\Python27\Lib\distutils\command\install.py", line 563, in run

    self.run_command('build')

  File "C:\Python27\Lib\distutils\cmd.py", line 326, in run_command

    self.distribution.run_command(command)

  File "C:\Python27\Lib\distutils\dist.py", line 972, in run_command

    cmd_obj.run()

  File "C:\Python27\Lib\distutils\command\build.py", line 127, in run

    self.run_command(cmd_name)

  File "C:\Python27\Lib\distutils\cmd.py", line 326, in run_command

    self.distribution.run_command(command)

  File "C:\Python27\Lib\distutils\dist.py", line 972, in run_command

    cmd_obj.run()

  File "C:\Python27\Lib\distutils\command\build_ext.py", line 340, in run

    self.build_extensions()

  File "C:\Users\s3z\Desktop\My Dropbox\pythons\ham\build\PIL\setup.py", line 368, in build_extensions

    build_ext.build_extensions(self)

  File "C:\Python27\Lib\distutils\command\build_ext.py", line 449, in build_extensions

    self.build_extension(ext)

  File "C:\Python27\Lib\distutils\command\build_ext.py", line 499, in build_extension

    depends=ext.depends)

  File "C:\Python27\Lib\distutils\msvc9compiler.py", line 469, in compile

    self.initialize()

  File "C:\Python27\Lib\distutils\msvc9compiler.py", line 379, in initialize

    vc_env = query_vcvarsall(VERSION, plat_spec)

  File "C:\Python27\Lib\distutils\msvc9compiler.py", line 295, in query_vcvarsall

    raise ValueError(str(list(result.keys())))

ValueError: [u'path']

----------------------------------------
Command "C:\Users\s3z\Desktop\My Dropbox\pythons\ham\Scripts\python.exe" -c "import setuptools;__file__='C:\\Users\\s3z\\Desktop\\My Dropbox\\
pythons\\ham\\build\\PIL\\setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-
managed --record c:\users\s3z\appdata\local\temp\pip-f7ttlx-record\install-record.txt --install-headers "C:\Users\s3z\Desktop\My Dropbox\pytho
ns\ham\include\site\python2.7" failed with error code 1 in C:\Users\s3z\Desktop\My Dropbox\pythons\ham\build\PIL
Storing complete log in C:\Users\s3z\AppData\Roaming\pip\pip.log

这里出了什么问题?以及如何在 virtualenv 中成功安装 PIL?

4

2 回答 2

7

使用 PIP 在 Windows 上安装 PIL 会给我带来问题,但使用 easy_install 可以正常工作。

“c:\VirtualENV\easy_install PIL”

于 2012-10-09T14:19:38.517 回答
2

PIL 是一个库,其中有一些部分是用 C 编写的,并且需要 Microsoft Visual C++ 来编译和构建一个完整的包。从错误消息中,它找不到 Microsoft Visual C++ 的路径。

如果您想从源代码安装(通过 PIP),您可以按照此博客中的说明进行操作

在 virtualenv 中使用 PIL 的一种更简单的方法是将PythonWare中的预编译二进制文件安装到 Python 站点包目录中。

然后使用选项重新创建您的 virtualenvvirtualenv --system-site-packages ENV 您的 virtualenv 将从全局站点包继承包。

于 2012-06-02T17:18:06.613 回答