为什么我无法安装autopy?

时间:2016-09-21 20:40:54

标签: python macos macos-sierra autopy

我正在使用MacBook和操作系统是MacOS Sierra。

我使用此命令安装autopy:

sudo pip install autopy

但是我收到了这个错误:

Collecting autopy
Downloading autopy-0.51.tar.gz (74kB)
100% |████████████████████████████████| 81kB 256kB/s 
Installing collected packages: autopy
 Running setup.py install for autopy ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-jSobWR/autopy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-lxk785-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.macosx-10.12-intel-2.7
creating build/lib.macosx-10.12-intel-2.7/autopy
copying autopy/__init__.py -> build/lib.macosx-10.12-intel-2.7/autopy
running build_ext
building 'color' extension
creating build/temp.macosx-10.12-intel-2.7
creating build/temp.macosx-10.12-intel-2.7/src
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -DNDEBUG=1 -DMM_LITTLE_ENDIAN -DIS_MACOSX -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/autopy-color-module.c -o build/temp.macosx-10.12-intel-2.7/src/autopy-color-module.o -Wall -Wparentheses -Winline -Wbad-function-cast -Wdisabled-optimization -Wshadow
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -DNDEBUG=1 -DMM_LITTLE_ENDIAN -DIS_MACOSX -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/MMBitmap.c -o build/temp.macosx-10.12-intel-2.7/src/MMBitmap.o -Wall -Wparentheses -Winline -Wbad-function-cast -Wdisabled-optimization -Wshadow
cc -bundle -undefined dynamic_lookup -arch x86_64 -arch i386 -Wl,-F. build/temp.macosx-10.12-intel-2.7/src/autopy-color-module.o build/temp.macosx-10.12-intel-2.7/src/MMBitmap.o -o build/lib.macosx-10.12-intel-2.7/autopy/color.so
building 'screen' extension
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -DNDEBUG=1 -DMM_LITTLE_ENDIAN -DIS_MACOSX -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/autopy-screen-module.c -o build/temp.macosx-10.12-intel-2.7/src/autopy-screen-module.o -Wall -Wparentheses -Winline -Wbad-function-cast -Wdisabled-optimization -Wshadow
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -DNDEBUG=1 -DMM_LITTLE_ENDIAN -DIS_MACOSX -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/screen.c -o build/temp.macosx-10.12-intel-2.7/src/screen.o -Wall -Wparentheses -Winline -Wbad-function-cast -Wdisabled-optimization -Wshadow
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -DNDEBUG=1 -DMM_LITTLE_ENDIAN -DIS_MACOSX -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/screengrab.c -o build/temp.macosx-10.12-intel-2.7/src/screengrab.o -Wall -Wparentheses -Winline -Wbad-function-cast -Wdisabled-optimization -Wshadow
src/screengrab.c:48:26: warning: implicit declaration of function 'CGDisplayBitsPerPixel' is invalid in C99 [-Wimplicit-function-declaration]
        bitsPerPixel = (uint8_t)CGDisplayBitsPerPixel(displayID);
                                ^
src/screengrab.c:174:15: warning: 'kCGLPFAFullScreen' is deprecated: first deprecated in macOS 10.6 [-Wdeprecated-declarations]
        attribs[0] = kCGLPFAFullScreen;
                     ^
/System/Library/Frameworks/OpenGL.framework/Headers/CGLTypes.h:98:2: note: 'kCGLPFAFullScreen' has been explicitly marked deprecated here
        kCGLPFAFullScreen OPENGL_ENUM_DEPRECATED(10_0, 10_6)     =  54,
        ^
src/screengrab.c:191:2: warning: 'CGLSetFullScreen' is deprecated: first deprecated in macOS 10.6 [-Wdeprecated-declarations]
        CGLSetFullScreen(glContext);
        ^
/System/Library/Frameworks/OpenGL.framework/Headers/OpenGL.h:73:17: note: 'CGLSetFullScreen' has been explicitly marked deprecated here
extern CGLError CGLSetFullScreen(CGLContextObj ctx) OPENGL_DEPRECATED(10_0, 10_6);
                ^
src/screengrab.c:194:2: warning: implicit declaration of function 'glReadBuffer' is invalid in C99 [-Wimplicit-function-declaration]
        glReadBuffer(GL_FRONT);
        ^
src/screengrab.c:194:15: error: use of undeclared identifier 'GL_FRONT'
        glReadBuffer(GL_FRONT);
                     ^
src/screengrab.c:197:2: warning: implicit declaration of function 'glFinish' is invalid in C99 [-Wimplicit-function-declaration]
        glFinish();
        ^
src/screengrab.c:199:6: warning: implicit declaration of function 'glGetError' is invalid in C99 [-Wimplicit-function-declaration]
        if (glGetError() != GL_NO_ERROR) return NULL;
            ^
src/screengrab.c:199:22: error: use of undeclared identifier 'GL_NO_ERROR'
        if (glGetError() != GL_NO_ERROR) return NULL;
                            ^
src/screengrab.c:207:2: warning: implicit declaration of function 'glPopClientAttrib' is invalid in C99 [-Wimplicit-function-declaration]
        glPopClientAttrib(); /* Clear attributes previously set. */
        ^
src/screengrab.c:223:2: warning: implicit declaration of function 'glPushClientAttrib' is invalid in C99 [-Wimplicit-function-declaration]
        glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
        ^
src/screengrab.c:223:21: error: use of undeclared identifier 'GL_CLIENT_PIXEL_STORE_BIT'
        glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
                           ^
src/screengrab.c:225:2: warning: implicit declaration of function 'glPixelStorei' is invalid in C99 [-Wimplicit-function-declaration]
        glPixelStorei(GL_PACK_ALIGNMENT, BYTE_ALIGN); /* Force alignment. */
        ^
src/screengrab.c:225:16: error: use of undeclared identifier 'GL_PACK_ALIGNMENT'
        glPixelStorei(GL_PACK_ALIGNMENT, BYTE_ALIGN); /* Force alignment. */
                      ^
src/screengrab.c:226:16: error: use of undeclared identifier 'GL_PACK_ROW_LENGTH'
        glPixelStorei(GL_PACK_ROW_LENGTH, 0);
                      ^
src/screengrab.c:227:16: error: use of undeclared identifier 'GL_PACK_SKIP_ROWS'
        glPixelStorei(GL_PACK_SKIP_ROWS, 0);
                      ^
src/screengrab.c:228:16: error: use of undeclared identifier 'GL_PACK_SKIP_PIXELS'
        glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
                      ^
src/screengrab.c:235:2: warning: implicit declaration of function 'glReadPixels' is invalid in C99 [-Wimplicit-function-declaration]
        glReadPixels(x, y, width, height,
        ^
src/screengrab.c:236:30: error: use of undeclared identifier 'GL_BGRA'
                     MMRGB_IS_BGR ? GL_BGRA : GL_RGBA,
                                    ^
src/screengrab.c:240:15: error: use of undeclared identifier 'GL_UNSIGNED_INT_8_8_8_8_REV'
                     GL_UNSIGNED_INT_8_8_8_8_REV, /* Native format */
                     ^
10 warnings and 9 errors generated.
error: command 'cc' failed with exit status 1

----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-jSobWR/autopy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-lxk785-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-jSobWR/autopy/

为什么我会收到此错误?

2 个答案:

答案 0 :(得分:3)

由于某些原因,有一个已知问题尚未解决。

问题:https://github.com/msanders/autopy/issues/75

它包含以下解决方法(在控制台中键入的命令):

brew install libpng
CFLAGS="-Wno-return-type" pip install git+https://github.com/potpath/autopy.git

答案 1 :(得分:0)

通常,它很容易工作,但如果没有,那就有点棘手了,您需要在终端上执行运行命令。 首先,通过运行以下命令检查二进制轮是否可用于您的机器:

$ pip install -U autopy

如果失败,安装 rustup 然后运行:

$ rustup default nightly-2019-10-05
$ pip install -U setuptools-rust
$ pip install -U autopy

有时 $ rustup default nightly-2019-10-05 由于所有软件包均不可用而不起作用,请运行 rustup install nightly 2019-10-05 --force。但是您必须确保 rustup 安装正确完成,因为它也需要安装 [BuildTools][2]