首页 > 解决方案 > django 无法构建 mysqlclient

问题描述

我在Window 7上创建了一个示例 Django 应用程序,我正在使用Python V3.6Django 2.1来处理我们计划使用 Mysql 数据库的应用程序。所以我尝试通过命令安装pip install django mysqlclient

Failed building wheel for mysqlclient
  Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient

  Running setup.py install for mysqlclient ... error
    Complete output from command c:\users\ccduce\appdata\local\continuum\miniconda3\python.exe -u -c "import setuptoo
ls, tokenize;__file__='C:\\Users\\ccduce\\AppData\\Local\\Temp\\pip-install-dw406d2r\\mysqlclient\\setup.py';f=getatt
r(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'
))" install --record C:\Users\ccduce\AppData\Local\Temp\pip-record-je8ir8xy\install-record.txt --single-version-exter
nally-managed --compile:
    c:\users\ccduce\appdata\local\continuum\miniconda3\lib\distutils\dist.py:261: UserWarning: Unknown distribution o
ption: 'long_description_content_type'
      warnings.warn(msg)
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.6
    copying _mysql_exceptions.py -> build\lib.win-amd64-3.6
    creating build\lib.win-amd64-3.6\MySQLdb
copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    running build_ext
    building '_mysql' extension

    error: [WinError 3] The system cannot find the path specified: 'C:\\Program Files (x86)\\Microsoft Visual Studio
14.0\\VC\\PlatformSDK\\lib'

    ----------------------------------------
Command "c:\users\ccduce\appdata\local\continuum\miniconda3\python.exe -u -c "import setuptools, tokenize;__file__='C
:\\Users\\ccduce\\AppData\\Local\\Temp\\pip-install-dw406d2r\\mysqlclient\\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\ccduce\AppData\Local\Temp\pip-record-je8ir8xy\install-record.txt --single-version-externally-managed --compile"
 failed with error code 1 in C:\Users\ccduce\AppData\Local\Temp\pip-install-dw406d2r\mysqlclient\

设置.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': '*****',
        'USER': '****',
        'PASSWORD': '******',
        'HOST': 'localhost',   # Or an IP Address that your DB is hosted on
        'PORT': '3306',
    }
}

我需要安装任何SDK来解决这个问题吗?

标签: pythonmysqldjango

解决方案


推荐阅读