在RHEL平台的mysql-sqlalchemy引擎中获取导入错误

时间:2017-04-04 06:49:13

标签: python mysql sqlalchemy rhel

我正在使用MySQL DB和SQLAlchemy ORM,我将导入错误为

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

我尝试安装libmysqlclient,但发现它仅用于ubuntu。 因此我尝试安装其RHEL替代mysql-devel,但它已经安装。请帮我解决这个问题,因为我不知道该怎么办。

1 个答案:

答案 0 :(得分:0)

重新安装mysql-python对我来说很有用。

pip uninstall mysql-python
pip uninstall mysql-python

虽然我仍然不知道导致错误的原因或重新安装如何解决它。