• 解决importerror no module named mysqldb


    系统:ubuntu
    语言:Python

    使用MySQLdb ,但是提示importerror no module named mysqldb

    Python中最连接Mysql常用的驱动是:

    mysql-python :mysql的C语言的驱动
    mysql-connector:msql官方的驱动
    pymysql:python语言的驱动
    

    我这里安装的是 mysql-python

    终端中执行:

    pip install mysql-python
    

    但是执行完,终端打印

    Collecting mysql-python
      Downloading MySQL-python-1.2.5.zip (108kB)
        100% |████████████████████████████████| 110kB 30kB/s 
        Complete output from command python setup.py egg_info:
        sh: mysql_config: command not found
        Traceback (most recent call last):
          File "<string>", line 20, in <module>
          File "/private/tmp/pip-build-NP8J3v/mysql-python/ setup.py", line 17, in <module>
            metadata, options = get_config()
          File "setup_posix.py", line 43, in get_config
            libs = mysql_config("libs_r")
          File "setup_posix.py", line 25, in mysql_config
            raise EnvironmentError("%s not found" %     (mysql_config.path,))
        EnvironmentError: mysql_config not found
    
    ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-NP8J3v/mysql-python
    

    如果忽略这个错误,那么在执行程序的时候回报错:importerror no module named mysqldb

    用以下方式解决:

    sudo apt-get install python-mysqldb
    
    pip install mysql-python  
    

    这样就可以了。

  • 相关阅读:
    移动 ProgramDataPackage Cache 文件夹
    Visual Studio 2017
    微信小程序 View:flex 布局
    echarts 模拟迁徙
    树莓派3 Windows 10 IoT Core
    Lumia 830 win10m 启用触摸按键
    青岛旅游
    <孤独者生存(小小辛巴投资手记)>读书笔记
    Python.Unix和Linux系统管理指南
    <低风险投资之路>读书笔记
  • 原文地址:https://www.cnblogs.com/fengtengfei/p/7468742.html
Copyright © 2020-2023  润新知