python安装mysqlclient_Python-安装mysqlclient(MySQLdb)

mysqlclient(也就是Python3版本的MySQLdb),性能比pymysql好,速度更快及PyMySQL的应用场景;所以一般大项目建议使用MySQLdb

使用pip安装

pip install mysqlclient

安装过程中可能会出现如下问题:

1114959-20200428093219388-1622726453.png

解决方法如下:

1)到https://www.lfd.uci.edu/~gohlke/pythonlibs/找到mysqlclient编译包下载对应版本

1114959-20200428093321295-1360348417.png

2)进入到文件下载到的位置,进行安装操作

1114959-20200428094307722-503042472.png

安装whl过程中,又遇到新的问题。

问题原因1:mysqlclient的版本和python版本不一致,下载的库名中cp27代表python2.7,我的是python3.8,版本一致

问题原因2:下载的是对应版本的库,然后仍然提示不支持当前平台,文件名格式不对

获取pip支持的文件名及格式:在shell中输入以下命令(64位要加上_internal,32位不需要)

importpip._internal.pep425tagsprint(pip._internal.pep425tags.get_supported())

1114959-20200428095842365-265157879.png

可以看到应该是win32,我下的是win64,所以不对,下载正确的文件后继续安装

1114959-20200428100048352-401515198.png

提示安装成功,问题解决了!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Python链接MySQL驱动包,安装之后可以使用Python语言链接MySQL进行数据库操作 # mysqlclient [![Build Status](https://secure.travis-ci.org/PyMySQL/mysqlclient-python.png)](http://travis-ci.org/PyMySQL/mysqlclient-python) This is a fork of [MySQLdb1](https://github.com/farcepest/MySQLdb1). This project adds Python 3 support and bug fixes. I hope this fork is merged back to MySQLdb1 like distribute was merged back to setuptools. ## Install ### Prerequisites You may need to install the Python and MySQL development headers and libraries like so: `sudo apt-get install python-dev libmysqlclient-dev` # Debian / Ubuntu `sudo yum install python-devel mysql-devel` # Red Hat / CentOS On Windows, there are binary wheel you can install without MySQLConnector/C or MSVC. #### Note on Python 3 : if you are using python3 then you need to install python3-dev using the following command : `sudo apt-get install python3-dev` # debian / Ubuntu `sudo yum install python3-devel ` # Red Hat / CentOS `brew install mysql-connector-c` # macOS (Homebrew) ### Install from PyPI `pip install mysqlclient` NOTE: Wheels for Windows may be not released with source package. You should pin version in your `requirements.txt` to avoid trying to install newest source package. ### Install from source 1. Download source by `git clone` or [zipfile](https://github.com/PyMySQL/mysqlclient-python/archive/master.zip). 2. Customize `site.cfg` 3. `python setup.py install` ### Documentation Documentation is hosted on [Read The Docs](https://mysqlclient.readthedocs.io/)

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值