Python安装PIL遇到‘Could not find a version that satisfies the requirement PIL’

问题重现:

PS C:\Windows\system32> pip install PIL

Collecting PIL
  Could not find a version that satisfies the requirement PIL (from versions: )
  Some externally hosted files were ignored as access to them may be unreliable (use --allow-external PIL to allow).

No matching distribution found for PIL

原因:

This is due to changes in the new version of Pip. Run pip --version and I'm willing to bet you are running 1.5. See the changelog here. This new default behavior enhances security. In PIL's case, the file you are installing actually comes from effbot.org (thus --allow-external) and PyPi doesn't have a checksum to guarantee validity (thus --allow-unverified).

Also, you might consider using the Pillow replacement to PIL.


加上--allow-external PIL --allow-unverified PIL选项

PS C:\Windows\system32> pip install PIL --allow-external PIL --allow-unverified PIL
Collecting PIL
  PIL is potentially insecure and unverifiable.
  Downloading http://effbot.org/media/downloads/PIL-1.1.7.tar.gz (506kB)
    100% |████████████████████████████████| 507kB 2.6MB/s
Building wheels for collected packages: PIL
  Running setup.py bdist_wheel for PIL
  Complete output from command C:\Python27\python.exe -c "import setuptools;__file__='c:\\users\\jay\\appdata\\local\\te
mp\\pip-build-ccr0hh\\PIL\\setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist
_wheel -d c:\users\jay\appdata\local\temp\tmpd1frnspip-wheel-:
  WARNING: '' not a valid package name; please use only.-separated package names in setup.py
  running bdist_wheel
  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
  error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from http://aka.ms/vcpython27


  ----------------------------------------
  Failed building wheel for PIL
Failed to build PIL
Installing collected packages: PIL
  Running setup.py install for PIL
    Complete output from command C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\jay\\appdat
a\\local\\temp\\pip-build-ccr0hh\\PIL\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('
\r\n', '\n'), __file__, 'exec'))" install --record c:\users\jay\appdata\local\temp\pip-7gvtci-record\install-record.txt
--single-version-externally-managed --compile:
    WARNING: '' not a valid package name; please use only.-separated package names in setup.py
    running install
    running build
    running build_py
    running build_ext
    building '_imaging' extension
    error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from http://aka.ms/vcpython27


    ----------------------------------------
Command "C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\jay\\appdata\\local\\temp\\pip-buil
d-ccr0hh\\PIL\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__,
'exec'))" install --record c:\users\jay\appdata\local\temp\pip-7gvtci-record\install-record.txt --single-version-externa
lly-managed --compile" failed with error code 1 in c:\users\jay\appdata\local\temp\pip-build-ccr0hh\PIL

按照要求去M$下载完再重新安装,成功。

PS C:\Windows\system32> pip install PIL --allow-external PIL --allow-unverified PIL
Collecting PIL
  PIL is potentially insecure and unverifiable.
  Downloading http://effbot.org/media/downloads/PIL-1.1.7.tar.gz (506kB)
    100% |████████████████████████████████| 507kB 3.4MB/s
Building wheels for collected packages: PIL
  Running setup.py bdist_wheel for PIL
  Stored in directory: C:\Users\Jay\AppData\Local\pip\Cache\wheels\ba\31\4a\9a5596f0640c9099a4302a71b56b7581e16e0d0b5a8f
30ce3e
Successfully built PIL
Installing collected packages: PIL
Successfully installed PIL-1.1.7
PS C:\Windows\system32> pip freeze
PIL==1.1.7
sinaweibopy==1.1.3
wheel==0.24.0

你可能感兴趣的:(python)