我无法将 MySQLdb 导入我的 Python 程序
I can't import MySQLdb to my Python Program
我需要在我的 Python 程序中使用 MySQL 数据库,所以我需要将 Python 连接到 MySQL。
我正在使用 MacOsX Sierra,我尝试安装连接器、mysqlclient,但没有任何效果。
我使用 PyCharm,每当我输入
import MySQLdb
或
import mysql.connector
我收到错误:
Traceback (most recent call last):
File "/Users/muhammed/Desktop/PyhtonHomework/venv/homework.py", line 1, in <module>
import MySQLdb
ModuleNotFoundError: No module named 'MySQLdb'
我该如何解决?我有一个学期项目,由于这个错误我什至无法开始。
Python版本:3.6.4
MySQLdb 不支持 Python 3. 尝试使用替代 MySQL Python 包。
我成功地将 MySQL Connector Python, specifically http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip 与 Python 一起使用 3 — 查看最新版本和使用文档。
pip install http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip
然后
import mysql.connector
使用可用的最新版本(我相信是 2.1.7)。
我需要在我的 Python 程序中使用 MySQL 数据库,所以我需要将 Python 连接到 MySQL。
我正在使用 MacOsX Sierra,我尝试安装连接器、mysqlclient,但没有任何效果。
我使用 PyCharm,每当我输入
import MySQLdb
或
import mysql.connector
我收到错误:
Traceback (most recent call last):
File "/Users/muhammed/Desktop/PyhtonHomework/venv/homework.py", line 1, in <module>
import MySQLdb
ModuleNotFoundError: No module named 'MySQLdb'
我该如何解决?我有一个学期项目,由于这个错误我什至无法开始。
Python版本:3.6.4
MySQLdb 不支持 Python 3. 尝试使用替代 MySQL Python 包。
我成功地将 MySQL Connector Python, specifically http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip 与 Python 一起使用 3 — 查看最新版本和使用文档。
pip install http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip
然后
import mysql.connector
使用可用的最新版本(我相信是 2.1.7)。