Windows 7 Python3.7 安装 mysqlclient

  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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容