0

I need mysql-python on my CentOS 7 server to run a script I wrote. I haven't found any success installing it I always get the following error:

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

I am running CentOS 7 and accessing my machine through ssh.

I have tried the following:
-Installing mysql-python on Centos
-can't install MySQL-Python python-dev is installed hopefully for the right version of python, gcc is also installed in fact I run:

# yum groupinstall "Developper Tools"  

-mysql_config not found when installing mysqldb python interface
Tried the solution provided here to install the package directly in the same directory as python 3.7 instead of the default one which was the one containing python 2.7:
https://unix.stackexchange.com/questions/323532/yum-install-package-name-to-different-directory
I # yum --installroot=/usr/local/bin/ --releasever=/ install MySQL-python
Per this I can't simply uninstall python 2.6:
-How to uninstall Python2.6

And I don't think simply creating an alias will solve my problem generally python 3 launches automatically not python 2 but my problem is regarding mysql-python

Essentially I think I have narrowed it down to the fact that I don't have mysql-python accessible to pthon 3.7 for some reason. It seems my 2 versions of python are somehow conflicting. I am wondering what I can do to fix this ? Before you suggest I tried running my program through python 2 but some exceptions I have to catch were not yet available.

All I want to do is get rid of this error message:

ModuleNotFoundError: No module named 'mysql'

Could someone please help me ? I wasn't sure whether it was better to post in unix.stackexchange.com but it seems appropriate to stackoverflow

shuri
  • 91
  • 3
  • 12

1 Answers1

1

The error you are getting (Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-mpl_yksf/mysql-python/) is because of a missing package ConfigParser.

In Python 3, ConfigParser was renamed to be configparser (all lowercase) to comply with PEP 8 standards. As of now, MySQL-python has not been updated to support Python 3.

You are left with two choices:

  1. Use Python 2 for whatever you are trying to do. This implies using pip2 command instead of pip3.

  2. Use an alternative package, such as mysqlclient.

To install mysqlclient, you will first need libmysqlclient-devel. Then you can install the Python 3 module via pip.

$ pip3 install mysqlclient
Abhishek Kumar
  • 461
  • 2
  • 11