I am working with MySQL DB and SQLAlchemy ORM where I am getting an Import Error as
Traceback (most recent call last):
File "main.py", line 5, in <module>
from pc import PC
File "*project_path*/pc.py", line 21, in <module>
from models import ABC, DEF
File "*project_path*/models.py", line 6, in <module>
engine = create_engine(conf.DATABASE_CONF, echo=False)
File "*home_path*/env/lib/python2.7/site-packages/sqlalchemy/engine/__init__.py", line 387, in create_engine
return strategy.create(*args, **kwargs)
File "*home_path*/env/lib/python2.7/site-packages/sqlalchemy/engine/strategies.py", line 80, in create
dbapi = dialect_cls.dbapi(**dbapi_args)
File "*home_path*/env/lib/python2.7/site-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 110, in dbapi
return __import__('MySQLdb')
File "*home_path*/env/lib/python2.7/site-packages/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory
I tried to install libmysqlclient but found out its only for ubuntu. Hence I tried to install its RHEL alternative mysql-devel but it was already installed. Please help me solve this bug as I am stuck not knowing what to do.
Reinstalling mysql-python did the trick for me.
pip uninstall mysql-python
pip uninstall mysql-python
Though I still don't know what caused the error or how reinstalling solved it.