How to install Python MySQLdb module using pip?

2019-01-01 10:10发布

How can I install the MySQLdb module for Python using pip?

标签: python mysql pip
18条回答
浅入江南
2楼-- · 2019-01-01 10:21

If pip3 isn't working, you can try:

sudo apt install python3-mysqldb
查看更多
人气声优
3楼-- · 2019-01-01 10:22

If you are use Raspberry Pi [Raspbian OS]

There are need to be install pip command at first

apt-get install python-pip

So that just install Sequently

apt-get install python-dev libmysqlclient-dev

apt-get install python-pip

pip install MySQL-python
查看更多
长期被迫恋爱
4楼-- · 2019-01-01 10:23

well this worked for me:

pip install mysqlclient

this is for python 3.x

查看更多
流年柔荑漫光年
5楼-- · 2019-01-01 10:23

pip install mysql-connector-python as noted in the documentation:

https://dev.mysql.com/doc/connector-python/en/connector-python-installation-binary.html

查看更多
初与友歌
6楼-- · 2019-01-01 10:25

on RHEL 7:

sudo yum install yum-utils mariadb-devel python-pip python-devel gcc

sudo /bin/pip2 install MySQL-python

查看更多
大哥的爱人
7楼-- · 2019-01-01 10:26

I tried all the option but was not able to get it working on Redhat platform. I did the following to make it work:-

yum install MySQL-python -y

Once the package was installed was able to import module as follows in the interpreter:-

>>> import MySQLdb
>>> 
查看更多
登录 后发表回答