尝试 python manage.py syncdb
但它给了我一个错误。与此处的许多其他问题类似,但提供的解决方案在我安装它们后并没有解决错误。
我的项目目录中的 settings.py
文件
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'network',
'USER': 'root',
'PASSWORD': 'mypass',
'HOST': '', #EMPTY FOR LOCALHOST
'PORT': '3307', #Empty by default
}
}
我正在使用 Windows 7,Python 3.4(我听说与安装 MySQL-python 不兼容,所以我下载了 mysqlclient 1.3.6)。
当我运行 easy_install mysql-python
时,结果是
_mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory
error: Setup script exited with error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\BIN\\cl.exe'
failed with exit status 2
同样,它在运行 pip install mysql-python
时要求 config-win.h,并出现可怕的错误
Command "D:\Users\Python\python.EXE -c "import setuptools, tokenize;__file__='C:\\Users\\AppData\\Local\\T
emp\\pip-build-w7q9kjxi\\mysql-python\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('
\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\AppData\Local\Temp\pip-u982sugf-record\install-record.t
xt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\AppData\Local\Temp\pip-build
-w7q9kjxi\mysql-python
我对此很困惑。我一直在看的教程在这里偏离了我,我不知道如何处理 mysqlclient 的 WHL。
我已经尝试过的事情:
easy_install Distribute
有效但不会改变任何东西python manage.py syncdb
没有名为“MySQLdb”的模块apt-get install python-mysqldb
根本无法识别术语“apt-get”。
请帮助解决这个初学者问题,感谢您抽出时间,如果需要更多信息,我很乐意提供。
最佳答案
如果没有 Visual Studio,您将需要 binary installer用于正确的 Python 版本和体系结构。最简单的方法可能是为已安装的 Python 版本同时获取 32 位和 64 位软件包,然后同时安装它们。
关于Python Django 安装mysql : easy_install and pip errors,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30408340/