解决windows64位系统上安装mysql-python报错
解决windows64位系统上安装mysql-python报错
?版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yu12377/article/details/79525470
一、 背景python项目中需要操作mysql,于是运行: pip install MySQL-python
报一连串的错误,前面的错误根据提示都好解决,但被下面的错误一直卡住,好一翻折腾才解决,所以在此记录以备忘。
二、 安装1. 安装64位版本的pythonhttps://www.python.org/ftp/python/2.7.14/python-2.7.14.amd64.msi 2. 安装VCForPython去微软官网下载? 根据错误提示,访问:http://aka.ms/vcpython27?C:UsersadminDesktop>pip install mysql-python Collecting mysql-python Using cached MySQL-python-1.2.5.zip Installing collected packages: mysql-python Running setup.py install for mysql-python ... error Complete output from command c:python27python.exe -u -c "import setuptools,tokenize;__file__=‘c:usersadminappdatalocaltemppip-build-srpbqqmysql-pythonsetup.py‘;f=getattr(tokenize,‘open‘,open)(__file__);code=f.read().replace(‘rn‘,‘n‘);f.close();exec(compile(code,__file__,‘exec‘))" install --record c:usersadminappdatalocaltemppip-6qgvvl-recordinstall-record.txt --single-version-externally-managed --compile: running install running build running build_py creating build creating buildlib.win-amd64-2.7 copying _mysql_exceptions.py -> buildlib.win-amd64-2.7 creating buildlib.win-amd64-2.7MySQLdb copying MySQLdb__init__.py -> buildlib.win-amd64-2.7MySQLdb copying MySQLdbconverters.py -> buildlib.win-amd64-2.7MySQLdb copying MySQLdbconnections.py -> buildlib.win-amd64-2.7MySQLdb copying MySQLdbcursors.py -> buildlib.win-amd64-2.7MySQLdb copying MySQLdbrelease.py -> buildlib.win-amd64-2.7MySQLdb copying MySQLdbtimes.py -> buildlib.win-amd64-2.7MySQLdb creating buildlib.win-amd64-2.7MySQLdbconstants copying MySQLdbconstants__init__.py -> buildlib.win-amd64-2.7MySQLdbconstants copying MySQLdbconstantsCR.py -> buildlib.win-amd64-2.7MySQLdbconstants copying MySQLdbconstantsFIELD_TYPE.py -> buildlib.win-amd64-2.7MySQLdbconstants copying MySQLdbconstantsER.py -> buildlib.win-amd64-2.7MySQLdbconstants copying MySQLdbconstantsFLAG.py -> buildlib.win-amd64-2.7MySQLdbconstants copying MySQLdbconstantsREFRESH.py -> buildlib.win-amd64-2.7MySQLdbconstants copying MySQLdbconstantsCLIENT.py -> buildlib.win-amd64-2.7MySQLdbconstants running build_ext building ‘_mysql‘ extension error: Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpython27 ---------------------------------------- Command "c:python27python.exe -u -c "import setuptools,‘exec‘))" install --record c:usersadminappdatalocaltemppip-6qgvvl-recordinstall-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:usersadminappdatalocaltemppip-build-srpbqqmysql-python C:UsersadminDesktop>
下载相应版本的VCForPython安装,再次安装mysql-python 3. 安装mysql-connector-python-2.1.7-py2.7-windows-x86-64bit.msihttps://cdn.mysql.com//Downloads/Connector-Python/mysql-connector-python-2.1.7-py2.7-windows-x86-64bit.msi 4. 安装mysql-connector-c-6.0.2-winx64.msihttps://cdn.mysql.com//Downloads/Connector-C/mysql-connector-c-6.0.2-winx64.msi? C:UsersadminDesktop>pip install mysql-python Collecting mysql-python Using cached MySQL-python-1.2.5.zip Installing collected packages: mysql-python Running setup.py install for mysql-python ... error Complete output from command c:python27python.exe -u -c "import setuptools,tokenize;__file__=‘c:usersadminappdatalocaltemppip-build-r8dkiwmysql-pythonsetup.py‘;f=getattr(tokenize,‘exec‘))" install --record c:usersadminappdatalocaltemppip-srrfzx-recordinstall-record.txt --single-version-externally-managed --compile: running install running build running build_py creating build creating buildlib.win-amd64-2.7 copying _mysql_exceptions.py -> buildlib.win-amd64-2.7 creating buildlib.win-amd64-2.7MySQLdb copying MySQLdb__init__.py -> buildlib.win-amd64-2.7MySQLdb copying MySQLdbconverters.py -> buildlib.win-amd64-2.7MySQLdb copying MySQLdbconnections.py -> buildlib.win-amd64-2.7MySQLdb copying MySQLdbcursors.py -> buildlib.win-amd64-2.7MySQLdb copying MySQLdbrelease.py -> buildlib.win-amd64-2.7MySQLdb copying MySQLdbtimes.py -> buildlib.win-amd64-2.7MySQLdb creating buildlib.win-amd64-2.7MySQLdbconstants copying MySQLdbconstants__init__.py -> buildlib.win-amd64-2.7MySQLdbconstants copying MySQLdbconstantsCR.py -> buildlib.win-amd64-2.7MySQLdbconstants copying MySQLdbconstantsFIELD_TYPE.py -> buildlib.win-amd64-2.7MySQLdbconstants copying MySQLdbconstantsER.py -> buildlib.win-amd64-2.7MySQLdbconstants copying MySQLdbconstantsFLAG.py -> buildlib.win-amd64-2.7MySQLdbconstants copying MySQLdbconstantsREFRESH.py -> buildlib.win-amd64-2.7MySQLdbconstants copying MySQLdbconstantsCLIENT.py -> buildlib.win-amd64-2.7MySQLdbconstants running build_ext building ‘_mysql‘ extension creating buildtemp.win-amd64-2.7 creating buildtemp.win-amd64-2.7Release C:UsersadminAppDataLocalProgramsCommonMicrosoftVisual C++ for Python9.0VCBinamd64cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,2,5,‘final‘,1) -D__version__=1.2.5 "-IC:Program Files (x86)MySQLMySQL Connector C 6.0.2include" -Ic:python27include -Ic:python27PC /Tc_mysql.c /Fobuildtemp.win-amd64-2.7Release_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:UsersadminAppDataLocalProgramsCommonMicrosoftVisual C++ for Python9.0VCBinamd64cl.exe‘ failed with exit status 2 ---------------------------------------- Command "c:python27python.exe -u -c "import setuptools,‘exec‘))" install --record c:usersadminappdatalocaltemppip-srrfzx-recordinstall-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:usersadminappdatalocaltemppip-build-r8dkiwmysql-python
5. MySQL-python-1.2.5.ziphttps://pypi.python.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip#md5=654f75b302db6ed8dc5a898c625e030c? 注意:即使已经安装了【mysql-connector-python】与【mysql-connector-c-6.0.2】,也可能会报上面的错误 原因: pypi上提供的MySQL-python包依赖32位的mysql-connector-c-6.0.2包,因为我们前面只安装了64位的版本,所有一直找不到mysql-connector-c-6.0.2而报上面的错误
pip install mysql-python
?
? connector = C:Program Files (x86)MySQLMySQL Connector C 6.0.2? # 源码安装 cd MySQL-python-1.2.5 python setup.py install
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 作为Windows服务运行的Python:OSError:[WinError 6]句柄无
- windows无人值守文件的制作_autounattend.xml
- 如何在Windows上修补?
- 在windows上添加ssh到PATH,我该怎么写?
- .net – 在哪里IBuffer byte [] .AsBuffer的扩展方法?
- windows – 需要XP管理员权限的旧应用程序
- assembly – Windows汇编程序和汇编程序编译器的指南
- windows-7 – 如何为Windows Vista / 7开发Metro应用程序UI
- 跨平台 – 使用Flutter在Windows环境中开发iOS设备
- HTTPERR日志关闭方法