8

I am getting an error

pip version

pip-3.3 -V pip 1.4.1 from /usr/local/lib/python3.3/site-packages/pip-1.4.1-py3.3.egg (python 3.3)

how to install MySQLdb in Python3.3 helpp..

root@thinkpad:~# pip-3.3 install MySQL-python 
Downloading/unpacking MySQL-python
  Downloading MySQL-python-1.2.4.zip (113kB): 113kB downloaded
  Running setup.py egg_info for package MySQL-python
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/tmp/pip_build_root/MySQL-python/setup.py", line 14, in <module>
        from setup_posix import get_config
      File "./setup_posix.py", line 2, in <module>
        from ConfigParser import SafeConfigParser
    ImportError: No module named 'ConfigParser'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/tmp/pip_build_root/MySQL-python/setup.py", line 14, in <module>

    from setup_posix import get_config

  File "./setup_posix.py", line 2, in <module>

    from ConfigParser import SafeConfigParser

ImportError: No module named 'ConfigParser'

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/MySQL-python
Storing complete log in /root/.pip/pip.log
2
  • Sadly, MySQL-python doesn't support Python 3 right now. You'll have to either rollback to python 2.x, or use another package. Source Commented Nov 18, 2013 at 14:17
  • 1
    See: stackoverflow.com/questions/27748556/… (pip install mysqlclient - a MySQL-python fork). Commented Feb 13, 2016 at 12:42

3 Answers 3

21

In python3 ConfigParser was renamed to configparser. It seems MySQL-python does not support python3. Try:

$ pip install PyMySQL

PyMySQL is a different module, but it supports python3.

Sign up to request clarification or add additional context in comments.

2 Comments

how to connect pymysqldb in django?
@PyDroid As Piotr Migdal said in his comment in Question. you should use mysqlclient for MySQL for Python3 in Django. docs.djangoproject.com/en/1.8/ref/databases/… Its recommended choice for using MySQL with Django.
4

In python3, install MySQL-python-1.2.5 by source, and before that, you need to modify source as mentioned below:

  • Replace ConfigParser by configparser in file MySQL-python-1.2.5/setup_posix.py file
  • Modify line 191, except TypeError, m: to except TypeError as m: in file MySQL-python-1.2.5/build/lib.linux-x86_64-3.4/MySQLdb/cursors.py file
  • Modify line 250, except TypeError, msg: to except TypeError as msg: in same cursors.py file
  • Modify line 36, raise errorclass, errorvalue to raise errorclass(errorvalue) in MySQL-python-1.2.5/build/lib.linux-x86_64-3.4/MySQLdb/connections.py file

To understand more, see Python3 porting guide.

Comments

1
pip install --allow-external mysql-connector-python

Edit settings.py

'ENGINE': 'mysql.connector.django',

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.