【发布时间】:2015-08-05 03:55:42
【问题描述】:
尝试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”根本无法识别。
请帮助解决这个初学者问题,感谢您的宝贵时间,如果需要更多信息,我很乐意提供。
【问题讨论】:
-
什么版本的 Django?
-
我认为是最近的 1.8.1
-
您显然正在查看一些过时的资源。你几乎不想使用
easy_install。而你肯定不想要distribute;这是一个过时的项目,已被setuptools取代。 -
无论如何,您的实际问题闻起来像
vcvarsall配置 Python 以使用 Visual Studio 的问题;搜索[python] vcvarsall,您应该会找到答案。