问题
I'm trying to use easy_install to install MySQL-python. It fails almost immediately:
_mysql.c:36:23: error: my_config.h: No such file or directory
_mysql.c:38:19: error: mysql.h: No such file or directory
_mysql.c:39:26: error: mysqld_error.h: No such file or directory
_mysql.c:40:20: error: errmsg.h: No such file or directory
It can't find the headers. I have the headers installed, they're just installed from source in /opt. It's obviously not looking there. How do I make it look there? For example, if this was configure, I could do something like "--with-mysql=/opt/mysql". It doesn't appear there is such an option with easy_install. Still researching so if I find my answer I'll post it here.
回答1:
This looks more like an issue with the compiler search path than a easy_install issu.
Setting the include path environment variable before the easy_install call may work.
C_INCLUDE_PATH=/path/to/your/mysql/include/files easy_install intall MySQL-python
If that doesn't work, try setting the INCLUDE_PATH or CPLUS_INCLUDE_PATH variables. There wasn't enough easy_install output in the question to tell what compiler is being used.
回答2:
easy_install
invokes setup.py
, which will respect a setup.cfg
file in the distribution it's trying to install. Although you cannot specify the setup.py options --include_dirs
and --library_dirs
directly to easy_install, you can put them in the setup.cfg file.
I have a similar issue with pysqlite: I put SQLite in a non-standard location, and wanted to use easy_install to get the Python bindings. The pysqlite distribution includes a setup.cfg file with sample include_dirs and library_dirs directives, so it was clear what to do.
If MySQL-python has a setup.cfg file, you could try adding / editing it to include:
[build_ext]
include_dirs = /path/to/headers
library_dirs = /path/to/libs
If there's already a [build_ext]
section in the setup.cfg file, add to it instead of creating a second one.
来源:https://stackoverflow.com/questions/4753127/python-easy-install-specify-directory-housing-required-files