MySQLdb - ModuleNotFoundError

好久不见. 提交于 2020-03-03 12:39:40

问题


I'm failing at importing MySQLdb: import MySQLdb results in:

ModuleNotFoundError: No module named 'MySQLdb'

I installed the following:

  1. pip install mysql-python
  2. pip install mysqlclient
  3. apt-get install python3-dev python-pip python-dev libmysqlclient-dev
  4. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!