zoukankan      html  css  js  c++  java
  • Windows下安装Python数据库模块--MySQLdb

    ## 1、下载MySQLdb
    [去官网](http://pypi.python.org/pypi/MySQL-python/)
    下载对应的编译好的版本(现在官网最新版本为1.2.5):
    MySQL-python-1.2.5.win32-py2.7.exe
    得到1MB的安装文件
    MySQL-python-1.2.5.win32-py2.7.exe
    ## 2、安装
    以上版本目前只支持到python2.7,在安装MySQLdb之前确定你已经在电脑上安装了python27。
    双击安装:
    这里写图片描述

    然后点下一步出现:
    这里写图片描述

    我确实已经安装了python 2.7
    究其原因是因为此x86的exe,是不支持我的win7 x64。
    ## 3、源码安装
    [下载源码] (https://pypi.python.org/pypi/MySQL-python/1.2.5)
    然后再去解压和安装,结果果然出现错误:

    error: Unable to find vcvarsall.bat

    D: mpdev_toolspythonmysqlMySQL-python-1.2.5MySQL-python-1.2.4>setup.py install
    Extracting in c:userscliappdatalocal emp mpkapo0l
    Now working in c:userscliappdatalocal emp mpkapo0ldistribute-0.6.28
    Building a Distribute egg in D: mpdev_toolspythonmysqlMySQL-python-1.2.4MySQL-python-1.2.4
    D: mpdev_toolspythonmysqlMySQL-python-1.2.4MySQL-python-1.2.4distribute-0.6.28-py2.7.egg
    running install
    running bdist_egg
    running egg_info
    writing MySQL_python.egg-infoPKG-INFO
    writing top-level names to MySQL_python.egg-info op_level.txt
    writing dependency_links to MySQL_python.egg-infodependency_links.txt
    writing MySQL_python.egg-infoPKG-INFO
    writing top-level names to MySQL_python.egg-info op_level.txt
    writing dependency_links to MySQL_python.egg-infodependency_links.txt
    reading manifest file ‘MySQL_python.egg-infoSOURCES.txt’
    reading manifest template ‘MANIFEST.in’
    writing manifest file ‘MySQL_python.egg-infoSOURCES.txt’
    installing library code to builddist.win-amd64egg
    running install_lib
    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 MySQLdb elease.py -> buildlib.win-amd64-2.7MySQLdb
    copying MySQLdb imes.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: Unable to find vcvarsall.bat
    D: mpdev_toolspythonmysqlMySQL-python-1.2.4MySQL-python-1.2.4>


    然后参考之前的办法,结果还是出错:

    D: mpdev_toolspythonmysqlMySQL-python-1.2.4MySQL-python-1.2.4>SET VS90COMNTOOLS=%VS100COMNTOOLS%
    D: mpdev_toolspythonmysqlMySQL-python-1.2.4MySQL-python-1.2.4>setup.py install
    running install
    running bdist_egg
    running egg_info
    writing MySQL_python.egg-infoPKG-INFO
    writing top-level names to MySQL_python.egg-info op_level.txt
    writing dependency_links to MySQL_python.egg-infodependency_links.txt
    writing MySQL_python.egg-infoPKG-INFO
    writing top-level names to MySQL_python.egg-info op_level.txt
    writing dependency_links to MySQL_python.egg-infodependency_links.txt
    reading manifest file ‘MySQL_python.egg-infoSOURCES.txt’
    reading manifest template ‘MANIFEST.in’
    writing manifest file ‘MySQL_python.egg-infoSOURCES.txt’
    installing library code to builddist.win-amd64egg
    running install_lib
    running build_py
    copying MySQLdb elease.py -> buildlib.win-amd64-2.7MySQLdb
    running build_ext
    building ‘_mysql’ extension
    creating build emp.win-amd64-2.7
    creating build emp.win-amd64-2.7Release
    C:Program Files (x86)Microsoft Visual Studio 10.0VCBINamd64cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,2,4,’final’,1) -D__version__=1.2.4 “-IC:Program Files (x86)MySQLMySQL
    Connector C 6.0.2include” -ID: mpdev_install_rootPython27_x64include -ID: mpdev_install_rootPython27_x64PC /Tc_mysql.c /Fobuild emp.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:Program Files (x86)Microsoft Visual Studio 10.0VCBINamd64cl.exe”’ failed with exit status 2
    D: mpdev_toolspythonmysqlMySQL-python-1.2.4MySQL-python-1.2.4>


    然后再参考:
    Windows下安装MySQLdb遇到的问题及解决方法
    所说的:
    1)问题 : _mysql.c(34) : fatal error C1083: Cannot open include file: ‘config-win.h’: No such file or directory
    error: command ‘”C:/Program Files/Microsoft Visual Studio 9.0/VC/BIN/cl.exe”‘ failed with exit status 2
    原因 :原因是安装MySQL的时候没有安装C语言库。
    解决 :重新运行MySQL的安装程序,选择Modify,把“C Include Files / Lib Files”勾选上,并安装。

  • 相关阅读:
    多维梯度下降
    梯度下降
    三种评价函数
    Gluon sgd
    Gluon.vision的几类数据集
    Gluon Data API
    Gluon 实现 dropout 丢弃法
    AlexNet 分类 FashionMNIST
    LeNet 分类 FashionMNIST
    LeNet
  • 原文地址:https://www.cnblogs.com/lanqiu5ge/p/9472230.html
Copyright © 2011-2022 走看看