Pip error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Issue

Installing collected packages: mysql-python, python-geoip, python-geoip-geolite2, python-dateutil, pytz, termcolor, werkzeug, semantic-version, rauth, redis, selenium, babel, scandir, pathlib2, pickleshare, simplegeneric, enum34, decorator, ipython-genutils, traitlets, backports.shutil-get-terminal-size, pygments, ptyprocess, pexpect, wcwidth, prompt-toolkit, ipython, html2text, email-reply-parser, click, num2words, PyYAML, argh, pathtools, watchdog, webencodings, html5lib, bleach, bleach-whitelist, Pillow, beautifulsoup4, rq, schedule, pycparser, cffi, asn1crypto, ipaddress, cryptography, zxcvbn, psutil, unittest-xml-reporting, xlwt, oauthlib, PyJWT, pypdf, frappe
  Running setup.py install for mysql-python ... error
    Complete output from command /home/frappe3/frappe-bench7/env/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-rWlGNb/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-Vy3nJU-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/frappe3/frappe-bench7/env/include/site/python2.7/mysql-python:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    copying _mysql_exceptions.py -> build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb
    copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb
    copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.7/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.7/MySQLdb
    copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
    copying MySQLdb/times.py -> build/lib.linux-x86_64-2.7/MySQLdb
    creating build/lib.linux-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    running build_ext
    building '_mysql' extension
    creating build/temp.linux-x86_64-2.7
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/usr/include/mysql/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o
    In file included from _mysql.c:44:0:
    /usr/include/mysql/my_config.h:3:2: warning: #warning This file should not be included by clients, include only <mysql.h> [-Wcpp]
     #warning This file should not be included by clients, include only <mysql.h>
      ^
    In file included from _mysql.c:46:0:
    /usr/include/mysql/mysql.h:440:3: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
       MYSQL_CLIENT_PLUGIN_HEADER
       ^
    _mysql.c: In function ‘_mysql_ConnectionObject_ping’:
    _mysql.c:2005:41: error: ‘MYSQL’ has no member named ‘reconnect’
      if ( reconnect != -1 ) self->connection.reconnect = reconnect;
                                             ^
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Solution

First Install following,

sudo apt-get install libmysqlclient-dev 

Then, I was installing frappe version 7 and using bench version 4.1.0 bench init --frappe-branch v7.x.x --verbose frappe-bench7 && cd frappe-bench7 command when encountered above issue and failed bench init process.

/home/frappe-bench7/env/bin/pip install mysql-python
2 Likes