python - 构建 MySQL Python 模块时出错

标签 python mysql mysql-python

我正在尝试为我的 Diskstation 1511 NAS(Intel Atom,嵌入式 Linux 2.6)构建 Python mysql 驱动程序安装。我有 MySQL-python-1.2.3。虽然 MySQL 安装在 NAS 上,但它不包含 mysql_config 实用程序,因此编译了一个完整的 MySQL 安装。

尝试构建时,我收到以下错误消息(详见下文)。 任何帮助表示赞赏。

DiskStation> python2.6 setup.py build
running build
running build_py
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.6/MySQLdb
running build_ext
building '_mysql' extension
/opt/bin/gcc -g -O2 -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/local/mysql-src/include/mysql -I/opt/include/python2.6 -c _mysql.c -o build/temp.linux-x86_64-2.6/_mysql.o
In file included from _mysql.c:36:
/usr/local/mysql-src/include/mysql/my_config.h:1063:1: warning: "SIZEOF_OFF_T" redefined
In file included from /opt/include/python2.6/Python.h:8,
                 from pymemcompat.h:10,
                 from _mysql.c:29:
/opt/include/python2.6/pyconfig.h:907:1: warning: this is the location of the previous definition
_mysql.c: In function '_escape_item':
_mysql.c:1050: warning: dereferencing type-punned pointer will break strict-aliasing rules
_mysql.c: In function 'init_mysql':
_mysql.c:2836: warning: dereferencing type-punned pointer will break strict-aliasing rules
_mysql.c:2838: warning: dereferencing type-punned pointer will break strict-aliasing rules
_mysql.c:2840: warning: dereferencing type-punned pointer will break strict-aliasing rules
_mysql.c:2842: warning: dereferencing type-punned pointer will break strict-aliasing rules
/opt/bin/gcc -shared -L/opt/lib -Wl,-rpath,/opt/lib -Wl,-rpath-link,/opt/lib build/temp.linux-x86_64-2.6/_mysql.o -L/usr/syno/mysql/lib/mysql -L/opt/lib -lmysqlclient_r -lz -lpthread -lcrypt -lnsl -lm -lpthread -lpython2.6 -o build/lib.linux-x86_64-2.6/_mysql.so
/opt/lib/gcc/i686-linux-gnu/4.2.1/../../../../i686-linux-gnu/bin/ld: cannot find -lmysqlclient_r
collect2: ld returned 1 exit status
error: command '/opt/bin/gcc' failed with exit status 1

最佳答案

我和上面有同样的错误。问题是它缺少一些头文件。快速谷歌显示它需要 python-dev,但它是针对默认 Python (2.7) 的。对于 python 2.6,有一个包 python2.6-dev。所以我们需要的是:

$ sudo apt-get install python2.6-dev

关于python - 构建 MySQL Python 模块时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8776934/

相关文章:

python - 为什么 Seaborn 会在我的数据中创建一个额外的类别?

Python tarfile - 检查 tar 中的文件是否存在于外部(即,已经被提取)

mysql - 根据列数据查找缺失行-MySQL

mysql - 在 SQL 中添加行之前检查表中是否存在行

python - Scrapy mysql 管道 runInteraction() 中的关键部分

python - 对两个多索引数据帧使用fillna会引发InvalidIndexError

javascript - 使用 javascript/AJAX 在 mysql 表中插入数据

python - 类型错误 : 'int' object is not iterable - Python

mysql - Flask uWSGI 失败,SQL_ALCHEMY_URI 设置为 MySQL 数据库

python - 由于类结构,Tkinter Return 键绑定(bind)不起作用