ubuntu20.04安装python2.7对应的mysql-python包

pip install mysql-python 出现以下错误:

    building '_mysql' extension
    creating build/temp.linux-x86_64-2.7
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-QDqKfA/python2.7-2.7.18=. -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: No such file or directory
       44 | #include "my_config.h"
          |          ^~~~~~~~~~~~~
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

亲测有效的解决办法为:

sudo apt-get install python2.7-dev default-libmysqlclient-dev build-essential
sudo wget https://raw.githubusercontent.com/paulfitz/mysql-connector-c/maste

你可能感兴趣的:(技术知识,python,mysql)