Django mysqldb模块无法在Windows Vista上安装:加载MySQLdb模块时出错:没有名为MySQLdb的模块

时间:2016-01-01 13:04:28

标签: python django mysql-python

我在Windows Vista平台上为django安装mysql-python模块时出现此错误:

  

django.core.exceptions.ImproperlyConfigured:加载MySQLdb模块时出错:没有名为MySQLdb的模块

我经历过错误' spat' out并尝试找到VC编译器正在寻找的config-wh文件,但无济于事,我不确定下一步该做什么(更新VC编译器(v9)或删除版本并坚持使用较低版本8 [已经在系统])。

原始输出:

Collecting MYSQl-python
  Using cached MySQL-python-1.2.5.zip
Installing collected packages: MYSQl-python
  Running setup.py install for MYSQl-python
    Complete output from command C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\i0101010\\appdata\\local\\temp\\pip-build-1vscsn\\MYSQl-python\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\i0101010\appdata\local\temp\pip-zui5a7-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-2.7
    copying _mysql_exceptions.py -> build\lib.win32-2.7
    creating build\lib.win32-2.7\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win32-2.7\MySQLdb
    copying MySQLdb\converters.py -> build\lib.win32-2.7\MySQLdb
    copying MySQLdb\connections.py -> build\lib.win32-2.7\MySQLdb
    copying MySQLdb\cursors.py -> build\lib.win32-2.7\MySQLdb
    copying MySQLdb\release.py -> build\lib.win32-2.7\MySQLdb
    copying MySQLdb\times.py -> build\lib.win32-2.7\MySQLdb
    creating build\lib.win32-2.7\MySQLdb\constants
    copying MySQLdb\constants\__init__.py -> build\lib.win32-2.7\MySQLdb\constants
    copying MySQLdb\constants\CR.py -> build\lib.win32-2.7\MySQLdb\constants
    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-2.7\MySQLdb\constants
    copying MySQLdb\constants\ER.py -> build\lib.win32-2.7\MySQLdb\constants
    copying MySQLdb\constants\FLAG.py -> build\lib.win32-2.7\MySQLdb\constants
    copying MySQLdb\constants\REFRESH.py -> build\lib.win32-2.7\MySQLdb\constants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win32-2.7\MySQLdb\constants

    running build_ext
    building '_mysql' extension
    creating build\temp.win32-2.7
    creating build\temp.win32-2.7\Release
    C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -IC:\Python27\include -IC:\Python27\PC /Tc_mysql.c /Fobuild\temp.win32-2.7\Release\_mysql.obj /Zl_mysql.c
    _mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h':No such file or directory
    error: command 'C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\BIN\\cl.exe' failed with exit status 2

    ----------------------------------------
Command "C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\i0101010\\appdata\\local\\temp\\pip-build-1vscsn\\MYSQl-python\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\i0101010\appdata\local\temp\pip-zui5a7-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\i0101010\appdata\local\temp\pip-build1vscsn\MYSQl-python

截图: enter image description here

1 个答案:

答案 0 :(得分:0)

我设法使用easy_install解决了这个问题。这解决了我的问题,我希望它也可以帮助那些人,不要仅仅依靠pip:)

easy_install MYSQL-python