Python Django MySQLdb 设置问题:setup.py 因 MySQL 位置错误无法构建

2 投票
2 回答
653 浏览
提问于 2025-04-15 23:53

我正在尝试为Python安装MySQLdb库。

但是当我运行安装程序时,出现了这个错误。

我知道为什么会出现缺少文件的提示,但不知道该如何更改加粗标记的那个位置。

请帮帮我。

gaurav-toshniwals-macbook-7:MySQL-python-1.2.3c1 gauravtoshniwal$ python setup.py build
running build
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.3-fat-2.6/MySQLdb
running build_ext
building '_mysql' extension
gcc-4.0 -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 -Dversion_info=(1,2,3,'gamma',1) -D__version__=1.2.3c1 **-I/Applications/MAMP/Library/include/mysql** -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _mysql.c -o build/temp.macosx-10.3-fat-2.6/_mysql.o
_mysql.c:36:23: error: my_config.h: No such file or directory
_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:38:19:_mysql.c:39:26: error: mysqld_error.h: No such file or directory
 error: _mysql.c:40:20:mysql.h: No such file or directory

2 个回答

0

上面的建议非常有用,但还值得提一下,你需要安装mysql-devel这个软件包,才能让你的构建成功。

0

这个路径可能是来自于 mysql_config 工具。你需要编辑一下你的 setup_posix.py 文件,把里面的 mysql_config.path 变量改成你正确的 mysql_config 工具的路径。

撰写回答