python3安装MySQL-python报错ImportError: No module named 'ConfigParser'解决方法

分类:开发相关    发布时间:2018-12-10 10:26:34

在python3中使用pip 安装MySQL-python时遇到 ImportError: No module named 'ConfigParser'错误,原因是MySQL-python不支持python3版本,可以使用mysqlclient软件包作为MySQL-python的代替,它是MySQL-python支持Python 3 的分支。

pip3 install mysqlclient

如果报错:

[root@Zabbix_test_wxs ~]# pip3 install mysqlclient
Collecting mysqlclient
  Using cached https://files.pythonhosted.org/packages/f7/a2/1230ebbb4b91f42ad6b646e59eb8855559817ad5505d81c1ca2b5a216040/mysqlclient-1.3.14.tar.gz
    Complete output from command python setup.py egg_info:
    /bin/sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-meg3rq5t/mysqlclient/setup.py", line 16, in <module>
        metadata, options = get_config()
      File "/tmp/pip-build-meg3rq5t/mysqlclient/setup_posix.py", line 53, in get_config
        libs = mysql_config("libs_r")
      File "/tmp/pip-build-meg3rq5t/mysqlclient/setup_posix.py", line 28, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    OSError: mysql_config not found


先安装以下依赖

yum install mysql-devel gcc gcc-devel python-devel


然后再安装mysqlclient

[root@Zabbix_test_wxs ~]# pip3 install mysqlclient
Collecting mysqlclient
  Using cached https://files.pythonhosted.org/packages/f7/a2/1230ebbb4b91f42ad6b646e59eb8855559817ad5505d81c1ca2b5a216040/mysqlclient-1.3.14.tar.gz
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient ... done
Successfully installed mysqlclient-1.3.14




标签: python

阅读(286)┆ 评论(0) ┆ (0) ┆ 返回博客首页


发表我的评论

欢迎您: | 退出登录


文章评论