问题
I'm failing at importing MySQLdb: import MySQLdb
results in:
ModuleNotFoundError: No module named 'MySQLdb'
I installed the following:
pip install mysql-python
pip install mysqlclient
apt-get install python3-dev python-pip python-dev libmysqlclient-dev
apt-get install python-mysqldb
(which according to this should suffice)
Here is my pip freeze | grep -i sql
:
mysqlclient==1.3.13
MySQL-python==1.2.5
I'm using Python 3.6 with PyCharm Community Edition on a virtual machine Ubuntu 18.04
What is missing here in order to use this? (also, is there another recommended module for Python API into mysql?)
Although this states there is no MySQLdb for Python3.X, this (and this) show it is alive and kicking, I think...
回答1:
You should use pip3
instead of pip
, since you are using Python 3.6.
Use pip for Python2.x
So your command should be like
pip3 install mysqlclient
来源:https://stackoverflow.com/questions/51245121/mysqldb-modulenotfounderror