美文网首页
Windows 7 Python3.7 安装 mysqlclie

Windows 7 Python3.7 安装 mysqlclie

作者: yumuxu | 来源:发表于2019-10-08 23:49 被阅读0次
    1. 网速较慢,设置使用清华大学开源软件镜像站,参考https://www.jianshu.com/p/d5b2b3bd5a3e
    pip3 install mysqlclient
    
    1. 提示需要安装VC++
      为什么会出现这样的错误
      Windows Python needs Visual C++ libraries installed via the SDK to build code, such as via setuptools.extension.Extension or numpy.distutils.core.Extension. For example, building f2py modules in Windows with Python requires Visual C++ SDK as installed above. On Linux and Mac, the C++ libraries are installed with the compiler.
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
    
    1. 查找对应的资源
      https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient
      其中cp27对应python2.7 win32表示window32位,win64表示windows64位系统。64位的不行安装32位的。
    pip3 install mysqlclient-1.4.4-cp37-cp37m-win32.whl
    Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
    Processing f:\sydownload\mysqlclient-1.4.4-cp37-cp37m-win32.whl
    Installing collected packages: mysqlclient
    Successfully installed mysqlclient-1.4.4
    
    1. 测试使用mysqlclinet
    Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit
    (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import MySQLdb
    >>> conn = MySQLdb.connect(host='localhost',port=3306,user='root',passwd='root',db='xxxx')
    >>> cur = conn.cursor()
    >>> cur.execute('select * from xxxxxxx;')
    13
    
    >>> cur.fetchall()
    ((2, '1BB1D9F3E1498E5CCBE899B451DE3548', 1551436800, 1553857200, 0, 0, '2357303'))...
    

    参考:
    https://www.scivision.dev/python-windows-visual-c-14-required/
    http://swiftlet.net/archives/2987

    相关文章

      网友评论

          本文标题:Windows 7 Python3.7 安装 mysqlclie

          本文链接:https://www.haomeiwen.com/subject/ldaipctx.html