我想将我的 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/
最佳答案
错误本身告诉我们问题是什么。
你试过吗
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
关于mysql - 将 Django 连接到 MySQL 错误 "Did you install mysqlclient?",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53314892/