python - 麻烦在ubuntu18.04上安装mysqlclient
问题描述
我正在尝试在 Ubuntu 18.04 上为 Django 项目安装 mysqlclient,但在安装 mysql 时遇到问题。以下是来自终端的信息:
pip install mysqlclient
Collecting mysqlclient
----------------------------------------
Failed building wheel for mysqlclient
Running setup.py clean for mysqlclient
2.7/MySQLdb/constants
running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/MySQLdb
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -
Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-PPrPZj/python2.7-2.7.15=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 -I/opt/lampp/include/mysql -I/opt/lampp/include/mysql/mysql -I/usr/include/python2.7 -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-2.7/MySQLdb/_mysql.o
MySQLdb/_mysql.c:29:10: fatal error: mysql.h: No such file or directory`enter code here`
#include "mysql.h"
^~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
解决方案
您必须安装 MySQL 标头。
sudo apt install libmysqlclient-dev
(停止使用 Python 2.7,一个月后就不再支持了)
推荐阅读
- apache-spark - 来自 ALS 模型的预测聚合 - SPARK 协作过滤
- arrays - 操作 Import-Csv 对象并逐行导出到文本文件
- ios - 如何混淆 Cordova 混合应用程序的 Objective C 代码?
- json - Power BI 自定义视觉对象 - 强制有向图 API 错误
- c# - 将二进制数据保存到表中时,我得到 NULL
- javascript - 如果字段有任何数据,应该看到添加按钮?onkeyup 功能不会每次都触发。我的目的是创建一个待办事项列表
- c# - AspNetCore Web Api 微软账户认证
- continuous-integration - Gitlab runner 使用共享运行器在 master 分支中运行我的 ci 部署
- algorithm - 如何计算算法的时间复杂度?
- javascript - 一页中具有不同参数的多个数据表