0

I am trying to run my Django Server with python 3.4.3 and have been scratching my head on this for a while. The commands I have tried so far, and their error messages, are:

pip3.4 install MySQLdb (No matching distribution found for mysqldb)

pip3.4 install mysql-python (ImportError: No module named 'ConfigParser')

pip3.4 install configparser
pip install ConfigParser
File "/tmp/pip-build-mcfc7tj3/ConfigParser/configparser.py", line 397
    _KEYCRE = re.compile(ur"%\(([^)]+)\)s")
                                         ^
SyntaxError: invalid syntax

pip3.4 install mysqlclient

File "/tmp/pip-build-s41j0x_s/mysqlclient/setup_posix.py", line 26, in mysql_config
    raise EnvironmentError("%s not found" % (mysql_config.path,))
OSError: mysql_config not found


sudo yum install python3-dev libmysqlclient-dev
No package python3-dev available.
No package libmysqlclient-dev available.

but still cannot get it installed. What should I do from here?

Notes:

Running python3.4 manage.py runserver threw

raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'
bryan.blackbee
  • 1,934
  • 4
  • 32
  • 46
  • Did you try python3.4 manage.py runserver? – Ahmed Hosny Feb 02 '16 at 11:30
  • MySQLdb is not supported on Python 3.4 - you need to use an [alternative driver](https://docs.djangoproject.com/en/1.9/ref/databases/#mysql-db-api-drivers) – Burhan Khalid Feb 02 '16 at 12:02
  • 2
    @BurhanKhalid further down the commands you can see that the OP tries to install `mysqlclient` which should work with Python 3. The problem is that they don't have the required development libraries installed for Python 3 and mysql. I'm not familiar with CentOS, so I don't know what the correct package names are. – Alasdair Feb 02 '16 at 12:06
  • @Alasdair I totally didn't see that ... You're right maybe, probably issue with centos. – ruddra Feb 02 '16 at 12:10
  • Thank you! I am using CentOS 7 by the way, hence the yum command – bryan.blackbee Feb 02 '16 at 12:16

1 Answers1

3

MySQLdb is not supported on Python 3.4 - you need to use an alternative driver

python-dev and mysql-dev are package names for the apt package system; which is used by debian, ubuntu and its clones/variants.

On CentOS you need the rpm-equivalent packages.

You should install mysql-devel for the MySQL development headers; you also need to have a development toolchain - the easiest way to install that is to issue sudo yum groupinstall "Development Tools".

Now, if you installed Python using yum as well, you need to install python-devel.

Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284