由于Warning和ValueError,无法在Windows中的virtualenv中安装PIL

时间:2012-04-26 13:23:13

标签: python windows python-imaging-library virtualenv pip

我正在尝试在virtualenv中安装PIL,但失败了。我创建了一个全新的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?

2 个答案:

答案 0 :(得分:7)

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

“c:\ VirtualENV \ easy_install PIL”

答案 1 :(得分:2)

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

如果您想从源代码安装(通过PIP),您可以按照this blog

中的说明进行操作

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

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