【问题标题】:mysqlclient for django in windowswindows中django的mysqlclient
【发布时间】:2020-06-14 16:52:09
【问题描述】:

我希望你做得很好!

我正在尝试使用 django 框架做应用程序,从 mysql 数据库中获取数据并对其进行报告。

我在windows中通过命令安装mysqlclient时遇到问题我尝试了很多但总是同样的错误

你们能给我建议吗?

顺便说一句,这是错误的家伙。

C:\Users\lenovo ideapad\Desktop\django-chartit\django-project\my_chartit>pip
install mysqlclient
Collecting mysqlclient
  Using cached mysqlclient-1.4.6.tar.gz (85 kB)
Installing collected packages: mysqlclient
    Running setup.py install for mysqlclient ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\lenovo ideapad\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\LENOVO~1\\AppData\\Local\\Temp\\pip-install-ntl230oc\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\LENOVO~1\\AppData\\Local\\Temp\\pip-install-ntl230oc\\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\LENOVO~1\AppData\Local\Temp\pip-record-5fst2b2v\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\lenovo ideapad\appdata\local\programs\python\python37-32\Include\mysqlclient'
         cwd: C:\Users\LENOVO~1\AppData\Local\Temp\pip-install-ntl230oc\mysqlclient\
    Complete output (30 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.7
    creating build\lib.win32-3.7\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\_exceptions.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\compat.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\connections.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\converters.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\cursors.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\release.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\times.py -> build\lib.win32-3.7\MySQLdb
    creating build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\__init__.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\CR.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\ER.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.7\MySQLdb\constants
    running build_ext
    building 'MySQLdb._mysql' extension
    creating build\temp.win32-3.7
    creating build\temp.win32-3.7\Release
    creating build\temp.win32-3.7\Release\MySQLdb
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include\mariadb" "-Ic:\users\lenovo ideapad\appdata\local\programs\python\python37-32\include" "-Ic:\users\lenovo ideapad\appdata\local\programs\python\python37-32\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /TcMySQLdb/_mysql.c /Fobuild\temp.win32-3.7\Release\MySQLdb/_mysql.obj /Zl /D_CRT_SECURE_NO_WARNINGS
    _mysql.c
    MySQLdb/_mysql.c(29): fatal error C1083: Impossible d'ouvrir le fichier includeÿ: 'mysql.h'ÿ: No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.24.28314\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\lenovo ideapad\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\LENOVO~1\\AppData\\Local\\Temp\\pip-install-ntl230oc\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\LENOVO~1\\AppData\\Local\\Temp\\pip-install-ntl230oc\\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\LENOVO~1\AppData\Local\Temp\pip-record-5fst2b2v\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\lenovo ideapad\appdata\local\programs\python\python37-32\Include\mysqlclient' Check the logs for full command output.

【问题讨论】:

    标签: mysql django database web-applications


    【解决方案1】:

    很多人在windows中用pip安装mysqlclient时遇到问题,似乎没有解决办法。 但是如果你使用 anaconda 你可以正确安装 mysqlclient。 使用 conda 创建虚拟环境并使用 pip install mysqlclient 命令安装 mysqlclient

    【讨论】:

    • 已经尝试过了,但是当我尝试运行我的应用程序时,它给了我一个错误,提示 mysqlclient 不存在
    • 你试过anaconda吗?你激活你的环境了吗?查看使用 conda list 命令安装了哪些软件包
    猜你喜欢
    • 2020-11-16
    • 2019-01-26
    • 1970-01-01
    • 2017-03-31
    • 2018-12-11
    • 2019-05-20
    • 2022-12-07
    • 2021-09-23
    相关资源
    最近更新 更多