如何在python中连接mysqldb时解决没有模块发现错误

时间:2017-09-18 07:06:05

标签: python python-3.x pip mysql-python

我收到此错误:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    import movies
  File "/home/xyz/topmovies/sample.py", line 3, in <module>
    import config
  File "/home/xyz/topmovies/config.py", line 1, in <module>
    import MySQLdb
ImportError: No module named MySQLdb

我通过使用pip,easy等不同的命令成功安装了mysqldb模块,我尝试了所有这些命令,

sudo pip install MYSQL-python
sudo apt-get build-dep python-mysqldb
sudo apt-get install python-pip python-dev libmysqlclient-dev
pip3 install http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip.

但我一次又一次地收到这个错误。请帮帮我。

1 个答案:

答案 0 :(得分:0)

使用: python3 -m pip install mysql-python
OR
python3 -m pip install mysqlclient