【问题标题】:Connect Django to MySQL ERROR "Did you install mysqlclient?"将 Django 连接到 MySQL 错误“您安装了 mysqlclient 吗?”
【发布时间】:2019-04-18 06:52:37
【问题描述】:

我想将我的 Django 项目连接到 MySQL。 我已经安装了mysqlclient 但是当我迁移项目“python3 manage.py migrate” 它有一个错误!!!

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?

我不知道如何解决它!请帮帮我

我尝试 $ pip3 install mysql-python 它错误!像这样:

Collecting mysql-python
  Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/cb/1r_2zrwn7597fzs9ktv0jbhh0000gn/T/pip-install-n72xlj1k/mysql-python/setup.py", line 13, in <module>
        from setup_posix import get_config
      File "/private/var/folders/cb/1r_2zrwn7597fzs9ktv0jbhh0000gn/T/pip-install-n72xlj1k/mysql-python/setup_posix.py", line 2, in <module>


           from ConfigParser import SafeConfigParser
        ModuleNotFoundError: No module named 'ConfigParser'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/cb/1r_2zrwn7597fzs9ktv0jbhh0000gn/T/pip-install-n72xlj1k/mysql-python/

【问题讨论】:

    标签: mysql django


    【解决方案1】:

    错误本身说明问题所在。

    你试过了吗

    pip install mysql-python
    

    如果这不起作用,请确保您安装了 python-dev install 。如果你在 ubuntu 上使用下面。

    apt-get install python3-mysqldb libmysqlclient-dev python-dev
    

    对于 mac 试试这个。

    $ brew uninstall mysql
    $ brew install mysql-connector-c
    $ brew unlink mysql-connector-c
    $ brew install mysql
    $ pip install mysql-python
    

    【讨论】:

    • 我先尝试它不起作用错误:命令“python setup.py egg_info”在/private/var/folders/cb/1r_2zrwn7597fzs9ktv0jbhh0000gn/T/pip-install-uqxsnr29/mysql中失败,错误代码为1 -python/
    • 和 python-dev install 它说找不到命令。我使用 Mac 操作系统
    • $ brew uninstall mysql :它说“错误:没有这样的小桶:/usr/local/Cellar/mysql” $ brew install mysql-connector-c :它说“警告:mysql-connector-c 6.1.11 已经安装并且是最新的” $ brew unlink mysql-connector-c : 它说“取消链接 /usr/local/Cellar/mysql-connector-c/6.1.11 ... 48 个符号链接被删除” $ brew install mysql :它的工作 $ pip install mysql-python :这是错误“命令“python setup.py egg_info”在/private/var/folders/cb/1r_2zrwn7597fzs9ktv0jbhh0000gn/T/pip-install-sj3d_t9o/mysql中出现错误代码1失败-python/"
    • 当我在评论中 $ pip install mysql-python 时更新错误
    猜你喜欢
    • 1970-01-01
    • 2018-12-25
    • 2022-01-21
    • 1970-01-01
    • 2018-11-30
    • 2020-03-07
    • 1970-01-01
    • 2018-04-04
    • 2022-07-21
    相关资源
    最近更新 更多