今天在 Fedora28 上安装 mysqlclient 时遇到这个问题怎么破 重新安装了 python3-devel 也没用

2018-05-27 23:11:29 +08:00
 TOUJOURSER
[root@node1 日 5 月 27 23:03:30 ~]# pip3 install mysqlclient
Collecting mysqlclient
Using cached https://files.pythonhosted.org/packages/6f/86/bad31f1c1bb0cc99e88ca2adb7cb5c71f7a6540c1bb001480513de76a931/mysqlclient-1.3.12.tar.gz
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-5tq296hs/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-_0mpq6cc/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
copying _mysql_exceptions.py -> build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.6/MySQLdb
creating build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.linux-x86_64-3.6
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -mcet -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,3,12,'final',0) -D__version__=1.3.12 -I/usr/include/mysql -I/usr/include/python3.6m -c _mysql.c -o build/temp.linux-x86_64-3.6/_mysql.o -m64
annobin: _mysql.c: Error: plugin built for compiler version (8.0.1) but run with compiler version (8.1.1)
cc1: 错误:无法初始化插件 /usr/lib/gcc/x86_64-redhat-linux/8/plugin/annobin.so
error: command 'gcc' failed with exit status 1

----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-5tq296hs/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-_0mpq6cc/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-5tq296hs/mysqlclient/
[root@node1 日 5 月 27 23:03:33 ~]#
2215 次点击
所在节点    Python
4 条回复
keramist
2018-05-27 23:42:52 +08:00
非常规 生产系统 不建议折腾 debian 首选
unlimitedsola
2018-05-27 23:59:05 +08:00
annobin: _mysql.c: Error: plugin built for compiler version (8.0.1) but run with compiler version (8.1.1)
看起来是因为 Fedora 的 gcc 版本太新导致的
msg7086
2018-05-28 04:05:53 +08:00
看上去是你的 gcc 没安装好。
把相关的包都升完了,保证你 gcc 的插件和 gcc 版本相同,然后再编译。
TOUJOURSER
2018-05-30 21:28:27 +08:00
yum install mysql-devel

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/458203

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX