title: Install python 3.6 mysqlclient for Django project on CentOS
body: <p>I have successfully installed a Django project on my CentOS 6.9. I have installed the project in a virtual environment which I have created using python3.6 <code>python3.6 -m venv env</code> I have activated the virtual env and I am now trying to run the app using;</p>
  
  <pre><code>python manage.py runserver 0.0.0.0:8000
  </code></pre>
  
  <p>When I run this command I get the following error;</p>
  
  <pre><code>Unhandled exception in thread started by &lt;function check_errors.&lt;locals&gt;.wrapper at 0x7f7f7c5d67b8&gt;
  Traceback (most recent call last):
    File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 26, in &lt;module&gt;
      import MySQLdb as Database
  ModuleNotFoundError: No module named 'MySQLdb'
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 228, in wrapper
      fn(*args, **kwargs)
    File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
      autoreload.raise_last_exception()
    File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 251, in raise_last_exception
      six.reraise(*_exception)
    File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
      raise value.with_traceback(tb)
    File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 228, in wrapper
      fn(*args, **kwargs)
    File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
      apps.populate(settings.INSTALLED_APPS)
    File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/apps/registry.py", line 108, in populate
      app_config.import_models()
    File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/apps/config.py", line 202, in import_models
      self.models_module = import_module(models_module_name)
    File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "&lt;frozen importlib._bootstrap&gt;", line 978, in _gcd_import
    File "&lt;frozen importlib._bootstrap&gt;", line 961, in _find_and_load
    File "&lt;frozen importlib._bootstrap&gt;", line 950, in _find_and_load_unlocked
    File "&lt;frozen importlib._bootstrap&gt;", line 655, in _load_unlocked
    File "&lt;frozen importlib._bootstrap_external&gt;", line 678, in exec_module
    File "&lt;frozen importlib._bootstrap&gt;", line 205, in _call_with_frames_removed
    File "/REMOVED/REMOVED/python3.6/softwareix/storefront/models.py", line 10, in &lt;module&gt;
      class Brand(models.Model):
    File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/db/models/base.py", line 124, in __new__
      new_class.add_to_class('_meta', Options(meta, app_label))
    File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/db/models/base.py", line 331, in add_to_class
      value.contribute_to_class(cls, name)
    File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/db/models/options.py", line 214, in contribute_to_class
      self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
    File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/db/__init__.py", line 33, in __getattr__
      return getattr(connections[DEFAULT_DB_ALIAS], item)
    File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/db/utils.py", line 211, in __getitem__
      backend = load_backend(db['ENGINE'])
    File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/db/utils.py", line 115, in load_backend
      return import_module('%s.base' % backend_name)
    File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "&lt;frozen importlib._bootstrap&gt;", line 978, in _gcd_import
    File "&lt;frozen importlib._bootstrap&gt;", line 961, in _find_and_load
    File "&lt;frozen importlib._bootstrap&gt;", line 950, in _find_and_load_unlocked
    File "&lt;frozen importlib._bootstrap&gt;", line 655, in _load_unlocked
    File "&lt;frozen importlib._bootstrap_external&gt;", line 678, in exec_module
    File "&lt;frozen importlib._bootstrap&gt;", line 205, in _call_with_frames_removed
    File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 30, in &lt;module&gt;
      'Did you install mysqlclient or MySQL-python?' % e
  django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'.
  Did you install mysqlclient or MySQL-python?
  </code></pre>
  
  <p>I see that I am missing Python mysql extension or driver. I have attempted to install it as suggested. When I run; <code>pip install mysqlclient</code> I get;</p>
  
  <pre><code>Collecting mysqlclient
    Using cached mysqlclient-1.3.10.tar.gz
  Installing collected packages: mysqlclient
    Running setup.py install for mysqlclient ... error
      Complete output from command /REMOVED/REMOVED/python3.6/env/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-7g3likz_/mysqlclient/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-y1mak800-record/install-record.txt --single-version-externally-managed --compile --install-headers /REMOVED/REMOVED/python3.6/env/include/site/python3.6/mysqlclient:
      running install
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.6
      copying _mysql_exceptions.py -&gt; build/lib.linux-x86_64-3.6
      creating build/lib.linux-x86_64-3.6/MySQLdb
      copying MySQLdb/__init__.py -&gt; build/lib.linux-x86_64-3.6/MySQLdb
      copying MySQLdb/compat.py -&gt; build/lib.linux-x86_64-3.6/MySQLdb
      copying MySQLdb/connections.py -&gt; build/lib.linux-x86_64-3.6/MySQLdb
      copying MySQLdb/converters.py -&gt; build/lib.linux-x86_64-3.6/MySQLdb
      copying MySQLdb/cursors.py -&gt; build/lib.linux-x86_64-3.6/MySQLdb
      copying MySQLdb/release.py -&gt; build/lib.linux-x86_64-3.6/MySQLdb
      copying MySQLdb/times.py -&gt; build/lib.linux-x86_64-3.6/MySQLdb
      creating build/lib.linux-x86_64-3.6/MySQLdb/constants
      copying MySQLdb/constants/__init__.py -&gt; build/lib.linux-x86_64-3.6/MySQLdb/constants
      copying MySQLdb/constants/CLIENT.py -&gt; build/lib.linux-x86_64-3.6/MySQLdb/constants
      copying MySQLdb/constants/CR.py -&gt; build/lib.linux-x86_64-3.6/MySQLdb/constants
      copying MySQLdb/constants/ER.py -&gt; build/lib.linux-x86_64-3.6/MySQLdb/constants
      copying MySQLdb/constants/FIELD_TYPE.py -&gt; build/lib.linux-x86_64-3.6/MySQLdb/constants
      copying MySQLdb/constants/FLAG.py -&gt; build/lib.linux-x86_64-3.6/MySQLdb/constants
      copying MySQLdb/constants/REFRESH.py -&gt; build/lib.linux-x86_64-3.6/MySQLdb/constants
      running build_ext
      building '_mysql' extension
      creating build/temp.linux-x86_64-3.6
      gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,3,10,'final',0) -D__version__=1.3.10 -I/usr/include/mysql -I/REMOVED/REMOVED/python3.6/env/include -I/usr/local/include/python3.6m -c _mysql.c -o build/temp.linux-x86_64-3.6/_mysql.o
      gcc: error trying to exec 'as': execvp: Permission denied
      error: command 'gcc' failed with exit status 1
  
      ----------------------------------------
  Command "/REMOVED/REMOVED/python3.6/env/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-7g3likz_/mysqlclient/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-y1mak800-record/install-record.txt --single-version-externally-managed --compile --install-headers /REMOVED/REMOVED/python3.6/env/include/site/python3.6/mysqlclient" failed with error code 1 in /tmp/pip-build-7g3likz_/mysqlclient/
  </code></pre>
  
  <p>This does not seem to work. I have tried to install severally packages using yum after searching the internet. I tried to install <code>yum install python3-devel</code> but this is not available (<code>No package python3-devel available.</code>) and I see it is supposed to be in the epel repository. So I did <code>yum search python dev</code> and I get this;</p>
  
  <pre><code>dbus-python-devel.x86_64 : Libraries and headers for dbus-python
  gstreamer-python-devel.x86_64 : Headers for developing programs that will use gstreamer-python
  libimobiledevice-python.x86_64 : Python bindings for libimobiledevice
  pyldb-devel.x86_64 : Development files for the Python bindings for the LDB library
  python-behave.noarch : Tools for the behavior-driven development, Python style
  python-cherrypy.noarch : Pythonic, object-oriented web development framework
  python-cherrypy2.noarch : Pythonic, object-oriented web development framework
  python-devel.x86_64 : The libraries and header files needed for Python development
  python-devel.i686 : The libraries and header files needed for Python development
  python-igraph-devel.x86_64 : Development files for igraph
  python-imaging-devel.x86_64 : Development files for python-imaging
  python-mozdevice.noarch : Mozilla-authored device management
  python-pyblock.x86_64 : Python modules for dealing with block devices
  python-pyldns.x86_64 : Header files, libraries and development documentation for ldns.
  python-pyside-devel.i686 : Development files for python-pyside
  python-pyside-devel.x86_64 : Development files for python-pyside
  python-tools.x86_64 : A collection of development tools included with Python
  python34-devel.i686 : Libraries and header files needed for Python 3 development
  python34-devel.x86_64 : Libraries and header files needed for Python 3 development
  wxPython-devel.i686 : Development files for wxPython add-on modules
  wxPython-devel.x86_64 : Development files for wxPython add-on modules
  python-pycxx-devel.noarch : PyCXX header and source files
  </code></pre>
  
  <p>This is what I have tried so far. I am trying to get my Django app running on MySQL but the extension or module does not appear to be installed.</p>