4

I am using python3 to install mysql-python package. So, when I run

pip install mysql-python,

it gives me error.

Tried using

pip install --upgrade setuptools

It shows

Collecting mysql-python
  Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-tu6ygqzj/mysql-python/setup.py", line 13, in <module>
        from setup_posix import get_config
      File "/tmp/pip-build-tu6ygqzj/mysql-python/setup_posix.py", line 2, in <module>
        from ConfigParser import SafeConfigParser
    **ImportError: No module named 'ConfigParser'**

----------------------------------------
***Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-tu6ygqzj/mysql-python/***

Successfully installed with all files in it.

phd
  • 82,685
  • 13
  • 120
  • 165
guneet kakkar
  • 71
  • 1
  • 1
  • 8
  • Possible duplicate of [Python 3 ImportError: No module named 'ConfigParser'](https://stackoverflow.com/questions/14087598/python-3-importerror-no-module-named-configparser) – phd Apr 03 '19 at 15:36
  • https://stackoverflow.com/search?q=%5Bmysql-python%5D+ImportError+No+module+named+ConfigParser – phd Apr 03 '19 at 15:36

3 Answers3

12

I guess you need to install the following:

pip install mysqlclient 

In Python 3, ConfigParser has been renamed to configparser for PEP 8 compliance.

mysqlclient is a fork of mysql-python, with Python 3 support.

Kindly make sure you have installed the following before installing mysqlclient:

sudo apt-get install python3-dev libmysqlclient-dev
Jeril
  • 7,858
  • 3
  • 52
  • 69
  • what has to be done for amazon linux 2 since it is giving me error '1 packages excluded due to repository priority protections' – darth vader Sep 24 '20 at 03:10
1

For Lunix and Mac Machines, install the mysqlclient pre-requisites via:

Debian / Ubuntu - sudo apt-get install python-dev default-libmysqlclient-dev

Red Hat / CentOS - sudo yum install python-devel mysql-devel

macOS (Homebrew) - brew install mysql-client

Dharman
  • 30,962
  • 25
  • 85
  • 135
Lewis
  • 2,718
  • 1
  • 11
  • 28
0

I tried to do this before that so after this it command work:

apt-get install libmysqlclient-dev
blackbrandt
  • 2,010
  • 1
  • 15
  • 32