【问题标题】:I have already installed libpng, but there is an error " 'png.h' file not found #include <png.h>" when I am installing the autopy我已经安装了 libpng,但是在安装 autopy 时出现错误“'png.h' file not found #include <png.h>”
【发布时间】:2014-09-23 02:06:48
【问题描述】:

我是python的初学者,最近我想在我的Mac(小牛队,10.9.4)中安装autopy。 我阅读了许多介绍和其他人的问题。但我仍然无法成功安装 autopy。我安装 autopy 的步骤如下:

  1. 我已经从http://ethan.tira-thompson.com/Mac_OS_X_Ports.html 安装了libpng
  2. 我是初学者,我检查了 /Library/Frameworks 和 /usr/local,我 认为我已经正确安装了 libpng
  3. [终端]git clone git://github.com/msanders/autopy.git
  4. 根据介绍,我在autopy文件“src/screengrab.c”的第七行写#include &lt;OpenGL/gl.h&gt;
  5. [终端]cd autopy
  6. [终端]python setup.py build

这里是命令窗口

src/png_io.c:3:10: fatal error: 'png.h' file not found
#include <png.h>
          ^
1 error generated.
error: command 'cc' failed with exit status 1

我需要重写png_io.c中“png.h”的文件地址吗?在Mac上安装autopy应该怎么做?我有一些重要的遗漏吗?

【问题讨论】:

  • 如果我正确理解了 libpng 页面,libpng 会将其头文件安装在 /usr/local/include/libpng 中,并将其库安装在 /usr/local/lib 中。您需要将autopy 的设置过程指向这些路径。

标签: python macos unix opengl libpng


【解决方案1】:

试试:

sudo apt-get install libpng-dev

我现在正在安装 autopy,并停留在同一步骤。安装 libpng-dev 后,问题解决了。 :)

安装autopy的完整过程如下

  1. sudo apt-get install libx11-dev 解决“#include”未找到错误
  2. sudo apt-get install libxtst-dev 解决“#include”未找到错误
  3. sudo apt-get install libpng-dev 解决“#include”未找到错误
  4. easy_install autopy

【讨论】:

    【解决方案2】:

    我每次尝试安装 autopy 时都会遇到这个问题。正如 Evert 在他对您的问题的评论中提到的,您的编译器找不到 libpng。如果您已经通过the link you mentioned 正确安装了它,那么您可以添加一些环境变量来帮助您的编译器找到它,而无需编辑源代码。

    这是一个适用于我在 OS X Yosemite (10.10.1) 上的完整示例:

    git clone git://github.com/msanders/autopy.git
    cd autopy
    export LIBRARY_PATH="/usr/local/lib:/usr/local/include/libpng"
    export C_INCLUDE_PATH="/usr/local/lib:/usr/local/include/libpng"
    python setup.py build
    sudo python setup.py install
    

    【讨论】:

    • 当我检查我的/usr/local/include 目录时,没有任何东西叫libpng。不过,我确实在此目录中看到了 png.hlibpng16
    【解决方案3】:

    在我确认 png.h 位于默认路径后

    /usr/local/include/png.h
    

    我运行了以下命令来强制这些路径作为构建的默认标志

    sudo CPPFLAGS='-I/usr/local/include/' LDFLAGS='-L/usr/local/lib/' python setup.py build
    

    它有效(在 OS X Yosemite 10.10.5 上)

    记得运行 install 版本的命令,并在尝试使用 AutoPy 之前 cd 退出 autopy 目录

    【讨论】:

      【解决方案4】:

      试试这个对我有用

      sudo add-apt-repository ppa:linuxuprising/libpng12
      sudo apt update
      sudo apt install libpng12-0
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-01-13
        • 1970-01-01
        • 2018-04-17
        • 1970-01-01
        • 1970-01-01
        • 2021-10-25
        • 2015-09-23
        • 2021-04-13
        相关资源
        最近更新 更多