python - 使用 pip 安装 MySQL-python 时出错

标签 python mysql django

当我尝试运行服务器时出现以下错误

django.core.exceptions.ImproperlyConfigured: 
Error loading MySQLdb module: No module named 'MySQLdb'

我尝试使用 pip install mysql-python,但它给了我这个错误:

Collecting mysql-python Using cached MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
  File "<string>", line 20, in <module>
  File "/tmp/pip-build-t81ezx2d/mysql-python/setup.py", line 13, in <module>
    from setup_posix import get_config
  File "/tmp/pip-build-t81ezx2d/mysql-python/setup_posix.py", line 2, in <module>
    from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'    
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-t81ezx2d/mysql-python

这些是我通过 pip 安装的模块:

alabaster==0.7.6
Babel==2.0
Django==1.8.3
docutils==0.12
Jinja2==2.8
MarkupSafe==0.23
mysql-connector-python==2.0.4
Pygments==2.0.2
pytz==2015.4
six==1.9.0
snowballstemmer==1.2.0
Sphinx==1.3.1
sphinx-rtd-theme==0.1.8

有什么帮助吗?

编辑:使用 mysqlclient 解决了问题, Mysql-python 不适用于 Python 3。

最佳答案

首先安装,然后就可以正常工作了。 apt-get install python-dev libmysqlclient-dev

关于python - 使用 pip 安装 MySQL-python 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32077977/

相关文章:

python - 基于另一个列值创建列,基于将值分配给输入列中的字符串值集

python - 尝试将 Django 模型转换为 XML 时出现 UnicodeEncodeError

python - Windows 上的 Celery + Django : debugging asynchronous tasks

python - 生成器是线程安全的吗?

php - 无法在 PHP 中显示来自 MySQL 数据库的图像

python - sqlalchemy,从mysql读取并写入内存

django - NGINX 502 错误网关 gunicorn 超时

python - Django 使用 Redis 进行缓存

python - 如何获取Python字典中的第一个值

两列上的 MySQL 外键 : integer AND string