基于Ubuntu和python2.7环境下使用pip2安装MySQLdb 模块时,分析以下报错:x86_64-linux-gnu-gcc -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -ffile-prefix-map=/build/python2.7-W40Ff2/python2.7-2.7.18=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o _mysql.c:44:10: fatal error: my_config.h: 没有那个文件或目录 44 | #include "my_config.h" | ^~~~~~~~~~~~~ compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 ---------------------------------------- ERROR: Command errored out with exit status 1: /usr/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-GSLFPu/mysql-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-GSLFPu/mysql-python/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-JTgNl6/install-r
时间: 2024-02-25 15:56:25 浏览: 314
Linux系统python2.7虚拟环境下使用pip install MySQL-python安装报错
这个报错的原因是缺少MySQL的开发库,可以执行以下命令安装:
```
sudo apt-get install libmysqlclient-dev
```
然后再执行安装MySQLdb模块的命令即可。
阅读全文