亚洲中字慕日产2020,大陆极品少妇内射AAAAAA,无码av大香线蕉伊人久久,久久精品国产亚洲av麻豆网站

資訊專欄INFORMATION COLUMN

Windows Python3環(huán)境 pip安裝 mysqlclient包

cikenerd / 1951人閱讀

摘要:環(huán)境下安裝包經(jīng)常會(huì)有各種環(huán)境方面的問題及報(bào)錯(cuò)。所以此次報(bào)錯(cuò)的原因就出來(lái)了,缺少了這個(gè)頭文件。所以其核心原因在于環(huán)境的依賴庫(kù)中不存在相關(guān)的文件。其它在上有網(wǎng)友提供了一個(gè)較為省事兒的解決辦法,直接下載現(xiàn)成的文件到本地進(jìn)行安裝資源地址。

Windows 環(huán)境下安裝python包經(jīng)常會(huì)有各種環(huán)境方面的問題及報(bào)錯(cuò)。 最近在python36/37下升級(jí)安裝mysqlclient包時(shí)產(chǎn)生了下面的錯(cuò)誤,不論是百度還是Stack Overflow上查找都沒有真正的解決方案,于是寫文章與大家一起分享下這類報(bào)錯(cuò)的解決方法。

報(bào)錯(cuò)信息:
Building wheels for collected packages: mysqlclient
  Running setup.py bdist_wheel for mysqlclient ... error
  Complete output from command "d:program filespythonpython36python.exe" -u -c "import setuptools, tokenize;__file__="C:Userszdl25AppDataLocalTemppip-install-83rodr64mysqlclientsetup.py";f=getattr(tokenize, "open", open)(__file__);code=f.read().replace("
", "
");f.close();exec(compile(code, __file__, "exec"))" bdist_wheel -d C:Userszdl25AppDataLocalTemppip-wheel-nlo8hs6x --python-tag cp36:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating buildlib.win-amd64-3.6
  copying _mysql_exceptions.py -> buildlib.win-amd64-3.6
  creating buildlib.win-amd64-3.6MySQLdb
  copying MySQLdb\__init__.py -> buildlib.win-amd64-3.6MySQLdb
  copying MySQLdbcompat.py -> buildlib.win-amd64-3.6MySQLdb
  copying MySQLdbconnections.py -> buildlib.win-amd64-3.6MySQLdb
  copying MySQLdbconverters.py -> buildlib.win-amd64-3.6MySQLdb
  copying MySQLdbcursors.py -> buildlib.win-amd64-3.6MySQLdb
  copying MySQLdb
elease.py -> buildlib.win-amd64-3.6MySQLdb
  copying MySQLdb	imes.py -> buildlib.win-amd64-3.6MySQLdb
  creating buildlib.win-amd64-3.6MySQLdbconstants
  copying MySQLdbconstants\__init__.py -> buildlib.win-amd64-3.6MySQLdbconstants
  copying MySQLdbconstantsCLIENT.py -> buildlib.win-amd64-3.6MySQLdbconstants
  copying MySQLdbconstantsCR.py -> buildlib.win-amd64-3.6MySQLdbconstants
  copying MySQLdbconstantsER.py -> buildlib.win-amd64-3.6MySQLdbconstants
  copying MySQLdbconstantsFIELD_TYPE.py -> buildlib.win-amd64-3.6MySQLdbconstants
  copying MySQLdbconstantsFLAG.py -> buildlib.win-amd64-3.6MySQLdbconstants
  copying MySQLdbconstantsREFRESH.py -> buildlib.win-amd64-3.6MySQLdbconstants
  running build_ext
  building "_mysql" extension
  creating build	emp.win-amd64-3.6
  creating build	emp.win-amd64-3.6Release
  C:Program Files (x86)Microsoft Visual Studio2017CommunityVCToolsMSVC14.15.26726inHostX86x64cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,3,13,"final",0) -D__version__=1.3.13 "-IC:Program Files (x86)MySQLMySQL Connector C 6.1include" "-Id:program filespythonpython36include" "-Id:program filespythonpython36include" "-IC:Program Files (x86)Microsoft Visual Studio2017CommunityVCToolsMSVC14.15.26726include" "-IC:Program Files (x86)Windows Kits10include10.0.10240.0ucrt" "-IC:Program Files (x86)Windows Kits8.1includeshared" "-IC:Program Files (x86)Windows Kits8.1includeum" "-IC:Program Files (x86)Windows Kits8.1includewinrt" "-IC:Program Files (x86)Windows Kits8.1includecppwinrt" /Tc_mysql.c /Fobuild	emp.win-amd64-3.6Release\_mysql.obj /Zl
  _mysql.c
  _mysql.c(29): fatal error C1083: 無(wú)法打開包括文件: “mysql.h”: No such file or directory
  error: command "C:Program Files (x86)Microsoft Visual Studio2017CommunityVCToolsMSVC14.15.26726inHostX86x64cl.exe" failed with exit status 2

  ----------------------------------------
  Failed building wheel for mysqlclient
  Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
  Found existing installation: mysqlclient 1.3.12
    Uninstalling mysqlclient-1.3.12:
      Successfully uninstalled mysqlclient-1.3.12
  Running setup.py install for mysqlclient ... error
    Complete output from command "d:program filespythonpython36python.exe" -u -c "import setuptools, tokenize;__file__="C:Userszdl25AppDataLocalTemppip-install-83rodr64mysqlclientsetup.py";f=getattr(tokenize, "open", open)(__file__);code=f.read().replace("
", "
");f.close();exec(compile(code, __file__, "exec"))" install --record C:Userszdl25AppDataLocalTemppip-record-f544g5zoinstall-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating buildlib.win-amd64-3.6
    copying _mysql_exceptions.py -> buildlib.win-amd64-3.6
    creating buildlib.win-amd64-3.6MySQLdb
    copying MySQLdb\__init__.py -> buildlib.win-amd64-3.6MySQLdb
    copying MySQLdbcompat.py -> buildlib.win-amd64-3.6MySQLdb
    copying MySQLdbconnections.py -> buildlib.win-amd64-3.6MySQLdb
    copying MySQLdbconverters.py -> buildlib.win-amd64-3.6MySQLdb
    copying MySQLdbcursors.py -> buildlib.win-amd64-3.6MySQLdb
    copying MySQLdb
elease.py -> buildlib.win-amd64-3.6MySQLdb
    copying MySQLdb	imes.py -> buildlib.win-amd64-3.6MySQLdb
    creating buildlib.win-amd64-3.6MySQLdbconstants
    copying MySQLdbconstants\__init__.py -> buildlib.win-amd64-3.6MySQLdbconstants
    copying MySQLdbconstantsCLIENT.py -> buildlib.win-amd64-3.6MySQLdbconstants
    copying MySQLdbconstantsCR.py -> buildlib.win-amd64-3.6MySQLdbconstants
    copying MySQLdbconstantsER.py -> buildlib.win-amd64-3.6MySQLdbconstants
    copying MySQLdbconstantsFIELD_TYPE.py -> buildlib.win-amd64-3.6MySQLdbconstants
    copying MySQLdbconstantsFLAG.py -> buildlib.win-amd64-3.6MySQLdbconstants
    copying MySQLdbconstantsREFRESH.py -> buildlib.win-amd64-3.6MySQLdbconstants
    running build_ext
    building "_mysql" extension
    creating build	emp.win-amd64-3.6
    creating build	emp.win-amd64-3.6Release
    C:Program Files (x86)Microsoft Visual Studio2017CommunityVCToolsMSVC14.15.26726inHostX86x64cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,3,13,"final",0) -D__version__=1.3.13 "-IC:Program Files (x86)MySQLMySQL Connector C 6.1include" "-Id:program filespythonpython36include" "-Id:program filespythonpython36include" "-IC:Program Files (x86)Microsoft Visual Studio2017CommunityVCToolsMSVC14.15.26726include" "-IC:Program Files (x86)Windows Kits10include10.0.10240.0ucrt" "-IC:Program Files (x86)Windows Kits8.1includeshared" "-IC:Program Files (x86)Windows Kits8.1includeum" "-IC:Program Files (x86)Windows Kits8.1includewinrt" "-IC:Program Files (x86)Windows Kits8.1includecppwinrt" /Tc_mysql.c /Fobuild	emp.win-amd64-3.6Release\_mysql.obj /Zl
    _mysql.c
    _mysql.c(29): fatal error C1083: 無(wú)法打開包括文件: “mysql.h”: No such file or directory
    error: command "C:Program Files (x86)Microsoft Visual Studio2017CommunityVCToolsMSVC14.15.26726inHostX86x64cl.exe" failed with exit status 2

    ----------------------------------------
  Rolling back uninstall of mysqlclient
Command ""d:program filespythonpython36python.exe" -u -c "import setuptools, tokenize;__file__="C:Userszdl25AppDataLocalTemppip-install-83rodr64mysqlclientsetup.py";f=getattr(tokenize, "open", open)(__file__);code=f.read().replace("
", "
");f.close();exec(compile(code, __file__, "exec"))" install --record C:Userszdl25AppDataLocalTemppip-record-f544g5zoinstall-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:Userszdl25AppDataLocalTemppip-install-83rodr64mysqlclient
原因排查

此類問題需要真正的會(huì)看且有耐心去看報(bào)錯(cuò)信息,根據(jù)報(bào)錯(cuò)去分析和思考問題出在哪個(gè)環(huán)節(jié)上,然后一步一步縮減范圍,鎖定問題原因。cl.exe" failed with exit status 2 基本上都是因?yàn)?strong>編譯過(guò)程中缺少必要的依賴庫(kù)文件所導(dǎo)致的。缺少哪個(gè)類庫(kù)文件,上面的報(bào)錯(cuò)信息會(huì)有指出來(lái)—— _mysql.c(29): fatal error C1083: 無(wú)法打開包括文件: “mysql.h”: No such file or directory。 所以此次報(bào)錯(cuò)的原因就出來(lái)了,缺少了 mysql.h 這個(gè)頭文件。

當(dāng)把mysql.h添加進(jìn)類庫(kù)后,還會(huì)報(bào) [ binary_log_types.h, errmsg.h, my_command.h, my_list.h, mysql_com.h, mysql_time.h, mysql_version.h, mysqld_error.h, mysql/client_plugin.h, mysql/plugin_auth_common.h, mysql/udf_registration_types.h ]。

所以其核心原因在于環(huán)境的依賴庫(kù)中不存在mysql相關(guān)的文件。去MySQL官方下載個(gè)MySQL-Server包[https://dev.mysql.com/downloa...],zip或者installer均可
,如果本機(jī)上已經(jīng)有MySQL-Server也行,到圖中MySQL-Server目錄中include中拷貝圖中選中的文件及文件夾到依賴庫(kù)目錄中去。

什么是依賴庫(kù)目錄?

上面的報(bào)錯(cuò)信息我們從下往上倒推,在“mysql.h”: No such file or directory這行往上第二行,報(bào)錯(cuò)中的 -IC:Program Files (x86)MySQLMySQL Connector C 6.1include, 在每一個(gè) -I 后面緊跟的就是系統(tǒng)會(huì)查找的庫(kù)目錄。只要其中任何一個(gè)路徑下能找到報(bào)錯(cuò)中需要依賴的頭文件就能讓安裝順利進(jìn)行下去。

雖然python的安裝目錄下的include文件夾也可以存放這些依賴文件,但如果你的系統(tǒng)中安裝有多個(gè)不同的python版本,那么為了避免復(fù)制多分這些依賴文件,還是建議放到其它目錄中,這樣不同Python版本下安裝都沒有問題。

大功告成了?

只差最后一步了。

以上的依賴庫(kù)文件添加完之后,還會(huì)再依賴一個(gè)靜態(tài)類庫(kù)文件。這個(gè)文件在 MySQL-Server/lib 中。

# 只截取以下關(guān)鍵錯(cuò)誤信息貼出
C:Program Files (x86)Microsoft Visual Studio 14.0VCBINx86_amd64link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO "/LIBPATH:C:Program Files (x86)MySQLMySQL Connector C 6.1libvs14" "/LIBPATH:D:Program FilesPythonPython37libs" "/LIBPATH:D:Program FilesPythonPython37PCbuildamd64" "/LIBPATH:C:Program Files (x86)Microsoft Visual Studio 14.0VCLIBamd64" "/LIBPATH:C:Program Files (x86)Windows Kits10lib10.0.10240.0ucrtx64" "/LIBPATH:C:Program Files (x86)Windows Kits8.1libwinv6.3umx64" kernel32.lib advapi32.lib wsock32.lib mysqlclient.lib /EXPORT:PyInit__mysql build	emp.win-amd64-3.7Release\_mysql.obj /OUT:buildlib.win-amd64-3.7\_mysql.cp37-win_amd64.pyd /IMPLIB:build	emp.win-amd64-3.7Release\_mysql.cp37-win_amd64.lib /MANIFEST
LINK : fatal error LNK1181: cannot open input file "mysqlclient.lib"
D:Program FilesPythonPython37libdistutilsdist.py:274: UserWarning: Unknown distribution option: "long_description_content_type"
  warnings.warn(msg)
error: command "C:Program Files (x86)Microsoft Visual Studio 14.0VCBINx86_amd64link.exe" failed with exit status 1181

根據(jù)以上報(bào)錯(cuò),將 mysqlclient.lib 文件從MySQL-Server那里拷貝到任意一個(gè) /LIBPATH即可!
OK.

總結(jié)

雖然今天對(duì)于我們來(lái)說(shuō)只是mysqlclient這個(gè)包的安裝問題,但其實(shí)還有很多網(wǎng)友在搜索許多類似原因?qū)е碌陌鼰o(wú)法正常安裝的問題,比如cudarray, pyltp, Scrapy等等,相信這篇文章一樣可以幫助他們找到解決方案。

其它
在Stack Overflow上有網(wǎng)友提供了一個(gè)較為省事兒的解決辦法,直接下載現(xiàn)成的.whl文件到本地進(jìn)行安裝(資源地址:https://www.lfd.uci.edu/~gohl...)。

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://www.ezyhdfw.cn/yun/42541.html

相關(guān)文章

  • python入門 django入門 (一)

    摘要:本人年開發(fā)經(jīng)驗(yàn),現(xiàn)就職于電信,因工作需要學(xué)習(xí),記錄自己的學(xué)習(xí)記錄。 本人java10年開發(fā)經(jīng)驗(yàn),現(xiàn)就職于電信,因工作需要學(xué)習(xí)python,記錄自己的學(xué)習(xí)記錄。后面也...

    hzc 評(píng)論0 收藏0
  • windows下mysql-python安裝出錯(cuò)(附python下載神器)(python2.7)

    摘要:下安裝出錯(cuò)注意用,從起,變更為安裝的驅(qū)動(dòng)是的但是毫不意外的出錯(cuò)了一般安裝運(yùn)行上面的神器命令都會(huì)出錯(cuò),即使在下也是,直接上解決辦法到下載二進(jìn)制安裝包網(wǎng)站打開大概是醬紫的通過(guò)搜索然后就醬紫了下載位版本然后運(yùn)行安裝然后稍等一下 windows下mysql-python安裝出錯(cuò) 注意:python2.x用mysql-python,從Python3.x起,變更為mysqlclient windo...

    pumpkin9 評(píng)論0 收藏0
  • Django中更改默認(rèn)數(shù)據(jù)庫(kù)為mysql

    摘要:中默認(rèn)使用數(shù)據(jù)庫(kù),今天研究了下如何將它換成常見的數(shù)據(jù)庫(kù)。由于項(xiàng)目用得,而沒有支持的版本,如果使用版本時(shí),時(shí)會(huì)報(bào)錯(cuò)。 Django中默認(rèn)使用sqlite3數(shù)據(jù)庫(kù),今天研究了下如何將它換成常見的mysql數(shù)據(jù)庫(kù)。 由于項(xiàng)目用得python3,而MySQLdb沒有支持python3的版本,如果使用python3.x版本時(shí),pip install MySQLdb時(shí)會(huì)報(bào)錯(cuò)。 后來(lái)通過(guò)谷歌發(fā)現(xiàn)...

    yunhao 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<