【问题标题】:Errors while installing python autopy安装 python autopy 时出错
【发布时间】:2012-10-20 22:06:35
【问题描述】:

嘿,我在这里看过一个老问题,但它没有回答我的问题

我已经安装了 libpng,然后尝试安装 autopy 并得到编译错误。

我还不是很擅长 python,所以我不确定如何修复它们。

Ashley:~ ashleyhughes$ sudo easy_install autopy
Searching for autopy
Reading http://pypi.python.org/simple/autopy/
Reading http://www.autopy.org
Best match: autopy 0.51
Downloading http://pypi.python.org/packages/source/a/autopy/autopy-0.51.tar.gz#md5=b92055aa2a3712a9c3b4c874014b450e
Processing autopy-0.51.tar.gz
Running autopy-0.51/setup.py -q bdist_egg --dist-dir /tmp/easy_install-U9uWoj/autopy-0.51/egg-dist-tmp-hdjtIx
clang: warning: argument unused during compilation: '-mno-fused-madd'
clang: warning: argument unused during compilation: '-mno-fused-madd'
clang: warning: argument unused during compilation: '-mno-fused-madd'
clang: warning: argument unused during compilation: '-mno-fused-madd'
clang: warning: argument unused during compilation: '-mno-fused-madd'
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:191:2: warning: 'CGLSetFullScreen' is deprecated
      [-Wdeprecated-declarations]
        CGLSetFullScreen(glContext);
        ^
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:236:40: error: use of undeclared identifier 'GL_RGBA'
                     MMRGB_IS_BGR ? GL_BGRA : GL_RGBA,
                                              ^
9 warnings and 9 errors generated.
error: Setup script exited with error: command 'clang' failed with exit status 1

谁能帮忙。我需要 autopy,因为它适用于多个平台

我使用 ethan.tira-thompson.com/Mac_OS_X_Ports.html 来安装 libpng

还使用命令行工具安装 xcode

【问题讨论】:

  • 只需edit您自己的问题即可添加额外信息。
  • 您似乎缺少 OpenGL 头文件。你安装 Xcode 了吗?
  • 是的,我有 xcode 还必须安装 xcode 命令行工具,因为 clang 丢失了
  • OP:这里有什么答案可以解决你的问题吗?

标签: python autopy


【解决方案1】:

我遇到了同样的问题,如果您注意到所有 9 个错误都来自一个文件: src/screengrab.c 此文件尚未更新到最新版本的 OpenGL,并且有一些已弃用的方法。在 autopy github repo 上报告了此 here. 的错误,修复/hack 建议添加以下行: #include <OpenGL/gl.h>

在 src/screengrab.c 的第 7 行之后。您将不得不从 Github 获取源代码并在本地进行更改,而不是使用 easy_install。
请注意,这是一个可以编译的 hack,但屏幕抓取将是全黑的。有人需要花几分钟用最新的方法重写 screengrab.c。

【讨论】:

    【解决方案2】:

    当我添加时

    #include <OpenGL/gl.h>
    

    它没有编译。

    所以,我查看了我的硬盘,寻找每个gl.h

    所以,我试过了

        #include "/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/gl.h"
    

    然后我设法编译它:-)

    【讨论】:

      【解决方案3】:

      如果你试过这个:

      $ sudo easy_install 自动安装

      另一种选择是从 GitHub 存储库上的最新源编译:

      $ git clone git://github.com/msanders/autopy.git

      $ cd 自动复制

      $ python setup.py build

      $ python setup.py 安装

      从源代码构建时,请确保在尝试使用 AutoPy 之前 cd 退出 autopy 目录,否则由于 Python 的相对导入,它可能会在 ImportError 上失败。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-09-23
        • 2011-09-02
        • 1970-01-01
        • 2017-04-29
        • 2021-02-07
        • 2014-08-30
        • 2018-12-03
        相关资源
        最近更新 更多