Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

ErrorwhileInstallingmysqlpythononCentOS7

While working through a Pluralsight tutorial, https://app.pluralsight.com/library/courses/docker-ansible-continuous-delivery/exercise-files, I'm having an issue getting mysql to work with django. Running pip install mysql-python produces this output:


    Collecting mysql-python
      Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
    Building wheels for collected packages: mysql-python
      Running setup.py bdist_wheel for mysql-python ... error
      Complete output from command /home/nick/dev/demos/todobackend/venv/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-YYanvu/mysql-python/setup.py';f=getattr(tokenize,
    'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-ED_q9B --python-tag cp27:
      running bdist_wheel
      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
      gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_
    SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE
     -fPIC -fwrapv -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 -m64
      _mysql.c:44:23: fatal error: my_config.h: No such file or directory
       #include "my_config.h"
                             ^
      compilation terminated.
      error: command 'gcc' failed with exit status 1

      ----------------------------------------
      Failed building wheel for mysql-python
      Running setup.py clean for mysql-python
    Failed to build mysql-python
    Installing collected packages: mysql-python
      Running setup.py install for mysql-python ... error
        Complete output from command /home/nick/dev/demos/todobackend/venv/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-YYanvu/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-NwBK4P/install-record.txt --single-version-exter
    nally-managed --compile --install-headers /home/nick/dev/demos/todobackend/venv/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
        gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GN
    U_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOUR
    CE -fPIC -fwrapv -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 -m64
        _mysql.c:44:23: fatal error: my_config.h: No such file or directory
         #include "my_config.h"
                               ^
        compilation terminated.
        error: command 'gcc' failed with exit status 1

        ----------------------------------------
    Command "/home/nick/dev/demos/todobackend/venv/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-YYanvu/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-NwBK4P/install-record.txt --single-version-externally-managed --compile
    --install-headers /home/nick/dev/demos/todobackend/venv/include/site/python2.7/mysql-python" failed with error code 1 in /tmp/pip-install-YYanvu/mysql-python/

I tried the following commands:

# yum install python-devel
# yum install mysql-devel
# yum install gcc

Also tried the steps described at Missing header files while installing packages using pip, but my issue still persists.

I'm not sure where to go from here.

Potential Solution

For this Pluralsight course the mysql-python library is used to run python manage.py test --settings=todobackend.settings.test However, unable to run pip install mysql-python, I decided to try a different library. So I tried PyMySQL

pip install PyMySQL

Also, I found I needed to run the following command to allow the --with-spec option to work.

pip install pinocchio==0.3.1

Comments