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
  • 69,888
  • 11
  • 97
  • 133
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
  • 6,538
  • 3
  • 47
  • 63
  • 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
  • 26,923
  • 21
  • 73
  • 125
Lewis
  • 2,438
  • 1
  • 10
  • 23
0

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

apt-get install libmysqlclient-dev
blackbrandt
  • 1,768
  • 14
  • 29