python - 无法在 django 1.11 中使用 python 2.7 连接 mysql,同时安装 mysqlclient 和 MySQL-python 时出现错误

标签 python mysql django

我正在尝试安装 mysql 客户端,以将 mysql 与 python 2.7 连接到 django 项目,但出现错误,即使我尝试安装 MySQL-python 连接器,但也出现错误。

C:\Users\syedabdul\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dve
rsion_info=(1,3,12,'final',0) -D__version__=1.3.12 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" -Ic:\python27\include -Ic:\pyt
hon27\PC /Tc_mysql.c /Fobuild\temp.win32-2.7\Release\_mysql.obj /Zl
    _mysql.c
    _mysql.c(29) : fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory
    error: command 'C:\\Users\\syedabdul\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with
exit status 2

    ----------------------------------------
Command "c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\syedab~1\\appdata\\local\\temp\\pip-build-xgy30p\\mysqlc
lient\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))
" install --record c:\users\syedab~1\appdata\local\temp\pip-rs9dvc-record\install-record.txt --single-version-externally-managed --compile" fail
ed with error code 1 in c:\users\syedab~1\appdata\local\temp\pip-build-xgy30p\mysqlclient\

最佳答案

我建议您从 pypi.python.org 使用适合您系统的官方 python 轮,然后通过 pip install MySQLConnector2.7.whl 进行安装(假设 MySQLConnector2.7.whl 是文件名)

关于python - 无法在 django 1.11 中使用 python 2.7 连接 mysql,同时安装 mysqlclient 和 MySQL-python 时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49293704/

相关文章:

django - vue js + django 应用架构

python - 在 Django 模板中减去 2 个整数

python - 表单中缺少 cleaned_data (django)

python - 查找 Python Math 和 CMath 模块的特定版本

python - 如何更改 Django 管理过滤器以使用下拉列表而不是也可以搜索的列表?

python - Flask - 如何重用 URL 参数替换函数?

mysql - 查询多天间隔表,按天分组计数?

python - 如何在Python中将二维数组添加到数据库中

python - 我应该为方法 `self` 参数使用什么类型?

c++ - QT MySql 数据库检查登录名和密码以登录