问题
I am a beginner at python, recently I want to install autopy in my Mac (Mavericks,10.9.4). I read many introductions and other people's questions. But I still cannot install the autopy successfully. My steps to install the autopy are as below:
- I have installed the libpng from the http://ethan.tira-thompson.com/Mac_OS_X_Ports.html
- I am beginner, I check the /Library/Frameworks and /usr/local and I think I have installed the libpng correctly
- [Terminal]
git clone git://github.com/msanders/autopy.git
- According to the introduction, I write
#include <OpenGL/gl.h>
at the seventh line of the autopy file "src/screengrab.c" - [Terminal]
cd autopy
- [Terminal]
python setup.py build
And here comes in the command window
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
Do I need to rewrite the file address of "png.h" in the png_io.c?And what should I do to install the autopy on Mac?Do I have some important Omissions?
回答1:
Try:
sudo apt-get install libpng-dev
I am installing autopy right now, and stuck at the same step. And after installing libpng-dev, the problem resolved. :)
The full process to install autopy is as follow
sudo apt-get install libx11-dev
to resolve "#include " not found errorsudo apt-get install libxtst-dev
to resolve "#include " not found errorsudo apt-get install libpng-dev
to resolve "#include " not found erroreasy_install autopy
回答2:
I have this problem every time I try to install autopy. As Evert mentioned in his comment on your question, your compiler can't find libpng
. If you have properly installed it via the link you mentioned, then you can add some environment variables that will help your compiler find it, without having to edit the source code.
Here's a complete example that works for me on 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
回答3:
After I confirmed that png.h was in a default path
/usr/local/include/png.h
I ran the following command to force these paths as default flags for the build
sudo CPPFLAGS='-I/usr/local/include/' LDFLAGS='-L/usr/local/lib/' python setup.py build
and it worked (on OS X Yosemite 10.10.5)
Remember to run the install version of the command, and to cd out of the autopy directory before attempting to use AutoPy
来源:https://stackoverflow.com/questions/25053647/i-have-already-installed-libpng-but-there-is-an-error-png-h-file-not-found