簡體   English   中英

Windows上的Python pip install django mysql失敗

[英]Python pip install django mysql fails on Windows

我正在嘗試使用Python 3.5和Django 1.9在Windows 10上設置django項目。 當我運行pip命令安裝MySQL支持時,出現以下錯誤。 MySQL 5.7已安裝並正在運行。

PS H:\> pip install django mysql
Requirement already satisfied (use --upgrade to upgrade): django in c:\python35\lib\site-packages
Collecting mysql
  Using cached mysql-0.0.1.tar.gz
Collecting MySQL-python (from mysql)
  Using cached MySQL-python-1.2.5.zip
Installing collected packages: MySQL-python, mysql
  Running setup.py install for MySQL-python
    Complete output from command c:\python35\python.exe -c "import setuptools, tokenize;__file__='C:\\Users\\JKRATZ~1.EVE\\AppData\\Local\\Temp\\pip-build-kr3v2d0u\\MySQL-python\\setup.py';exec(compile(get
attr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\JKRATZ~1.EVE\AppData\Local\Temp\pip-id62narl-record\install-record.txt --single-version-ex
ternally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.5
    copying _mysql_exceptions.py -> build\lib.win-amd64-3.5
    creating build\lib.win-amd64-3.5\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win-amd64-3.5\MySQLdb
    copying MySQLdb\converters.py -> build\lib.win-amd64-3.5\MySQLdb
    copying MySQLdb\connections.py -> build\lib.win-amd64-3.5\MySQLdb
    copying MySQLdb\cursors.py -> build\lib.win-amd64-3.5\MySQLdb
    copying MySQLdb\release.py -> build\lib.win-amd64-3.5\MySQLdb
    copying MySQLdb\times.py -> build\lib.win-amd64-3.5\MySQLdb
    creating build\lib.win-amd64-3.5\MySQLdb\constants
    copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.5\MySQLdb\constants
    copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.5\MySQLdb\constants
    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.5\MySQLdb\constants
    copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.5\MySQLdb\constants
    copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.5\MySQLdb\constants
    copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.5\MySQLdb\constants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.5\MySQLdb\constants
    running build_ext
    building '_mysql' extension
    creating build\temp.win-amd64-3.5
    creating build\temp.win-amd64-3.5\Release
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Co
nnector C 6.0.2\include" -Ic:\python35\include -Ic:\python35\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCL
UDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\shar
ed" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\winrt" /Tc_mysql.c /Fobuild\temp.win-amd64-3.5\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 (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\amd64\\cl.exe' failed with exit status 2

    ----------------------------------------
Command "c:\python35\python.exe -c "import setuptools, tokenize;__file__='C:\\Users\\JKRATZ~1.EVE\\AppData\\Local\\Temp\\pip-build-kr3v2d0u\\MySQL-python\\setup.py';exec(compile(getattr(tokenize, 'open', o
pen)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\JKRATZ~1.EVE\AppData\Local\Temp\pip-id62narl-record\install-record.txt --single-version-externally-managed --compi
le" failed with error code 1 in C:\Users\JKRATZ~1.EVE\AppData\Local\Temp\pip-build-kr3v2d0u\MySQL-python

在Windows上安裝對Django的MySQL支持的過程很痛苦,就像您一樣,我遇到了同樣的問題。 對於我的情況,我使用python3.4,django1.8.5,我通過從此處下載wheel文件並使用pip進行安裝解決了此問題:

pip install ***.whl

我認為查找包含文件“ config-win.h”存在問題。

請檢查以下錯誤消息:

_mysql.c(42): fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory

已將包含文件移至單獨的文件夾。
現在它們應該位於:

C:\\ Program Files \\ MySQL \\ Connector C 6.0.2 \\ include

請嘗試使用此鏈接中的說明:
在安裝mysql-python時“無法打開包含文件:'config-win.h':沒有這樣的文件或目錄”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM