【问题标题】:How to install PIL with pip+mingw in windows?如何在 Windows 中使用 pip+mingw 安装 PIL?
【发布时间】:2013-05-15 14:14:46
【问题描述】:

我正在尝试使用 pip 和 mingw 安装 PIL。但是失败如下。

Downloading/unpacking PIL
  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
    C:\MinGW\bin\gcc.exe -mdll -O -Wall -IlibImaging -IC:\Python27\include -IC:\Python27\include -IC:\Python27\PC -c _imaging.c -o build\temp.win32-2.7\Release\_imaging.o
    _imaging.c: In function 'init_imaging':
    _imaging.c:3253:15: warning: variable 'd' set but not used [-Wunused-but-set-variable]
    C:\MinGW\bin\gcc.exe -mdll -O -Wall -IlibImaging -IC:\Python27\include -IC:\Python27\include -IC:\Python27\PC -c decode.c -o build\temp.win32-2.7\Release\decode.o
    C:\MinGW\bin\gcc.exe -mdll -O -Wall -IlibImaging -IC:\Python27\include -IC:\Python27\include -IC:\Python27\PC -c encode.c -o build\temp.win32-2.7\Release\encode.o
    C:\MinGW\bin\gcc.exe -mdll -O -Wall -IlibImaging -IC:\Python27\include -IC:\Python27\include -IC:\Python27\PC -c map.c -o build\temp.win32-2.7\Release\map.o
    In file included from c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/winnt.h:192:0,
                     from c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/windef.h:253,
                     from c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/windows.h:48,
                     from map.c:35:
    c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/basetsd.h:50:21: error: duplicate 'signed'
    c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/basetsd.h:50:21: error: two or more data types in declaration specifiers
    c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/basetsd.h:51:22: error: duplicate 'short'
    c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/basetsd.h:56:23: error: duplicate 'unsigned'
    c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/basetsd.h:56:23: error: two or more data types in declaration specifiers
    c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/basetsd.h:57:24: error: duplicate 'unsigned'
    c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/basetsd.h:57:24: error: duplicate 'short'
    error: command 'gcc' failed with exit status 1
    Complete output from command C:\Python27\python.exe -c "import setuptools;__file__='c:\\users\\marshall\\appdata\\local\\temp\\pip-build-marshall\\PIL\\setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\marshall\appdata\local\temp\pip-pnnyve-record\install-record.txt --single-version-externally-managed:
    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

C:\MinGW\bin\gcc.exe -mdll -O -Wall -IlibImaging -IC:\Python27\include -IC:\Python27\include -IC:\Python27\PC -c _imaging.c -o build\temp.win32-2.7\Release\_imaging.o

_imaging.c: In function 'init_imaging':

_imaging.c:3253:15: warning: variable 'd' set but not used [-Wunused-but-set-variable]

C:\MinGW\bin\gcc.exe -mdll -O -Wall -IlibImaging -IC:\Python27\include -IC:\Python27\include -IC:\Python27\PC -c decode.c -o build\temp.win32-2.7\Release\decode.o

C:\MinGW\bin\gcc.exe -mdll -O -Wall -IlibImaging -IC:\Python27\include -IC:\Python27\include -IC:\Python27\PC -c encode.c -o build\temp.win32-2.7\Release\encode.o

C:\MinGW\bin\gcc.exe -mdll -O -Wall -IlibImaging -IC:\Python27\include -IC:\Python27\include -IC:\Python27\PC -c map.c -o build\temp.win32-2.7\Release\map.o

In file included from c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/winnt.h:192:0,

                 from c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/windef.h:253,

                 from c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/windows.h:48,

                 from map.c:35:

c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/basetsd.h:50:21: error: duplicate 'signed'

c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/basetsd.h:50:21: error: two or more data types in declaration specifiers

c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/basetsd.h:51:22: error: duplicate 'short'

c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/basetsd.h:56:23: error: duplicate 'unsigned'

c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/basetsd.h:56:23: error: two or more data types in declaration specifiers

c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/basetsd.h:57:24: error: duplicate 'unsigned'

c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/basetsd.h:57:24: error: duplicate 'short'

error: command 'gcc' failed with exit status 1

----------------------------------------
Command C:\Python27\python.exe -c "import setuptools;__file__='c:\\users\\marshall\\appdata\\local\\temp\\pip-build-marshall\\PIL\\setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\marshall\appdata\local\temp\pip-pnnyve-record\install-record.txt --single-version-externally-managed failed with error code 1 in c:\users\marshall\appdata\local\temp\pip-build-marshall\PIL
Storing complete log in C:\Users\marshall\pip\pip.log

我该如何解决这个问题?

【问题讨论】:

    标签: python mingw python-imaging-library pip


    【解决方案1】:

    INT8、INT16、UINT8、UINT16 定义为 int PIL 源

    您可以在 c:\mingw\include\basetsd.h 中添加#ifndef..#endif

    +#ifndef INT8
     typedef signed char INT8;
    +#endif
    

    适用于每种类型。 (其中“+”表示添加的行)

    它有效。

    【讨论】:

      【解决方案2】:

      我建议使用预构建的安装程序。请参阅PIL Unofficial Windows Binary,尽管我强烈推荐Pillow(也可作为安装程序从同一链接获得)。

      【讨论】:

      • Pillow 实际上使用 pip 可以很好地安装,谢谢!但是,如果您真的无法在 Windows 中使用 pip 安装基本软件包,这似乎是一种耻辱。
      • @marshall 如果包需要编译器,这通常只是一个问题,但是是的,它并不总是很方便。
      猜你喜欢
      • 2013-05-09
      • 2021-09-27
      • 1970-01-01
      • 2014-10-04
      • 2015-09-06
      • 2019-05-23
      • 1970-01-01
      • 2014-03-27
      • 2015-03-18
      相关资源
      最近更新 更多