Ich benutze Python 3 und ich wollte MySQLdb für Python installieren. Ich heruntergeladene tar.gz-Datei von diesem link .Dann extrahiert und MySQLdb
Ordner wurde in Lib-Ordner kopiert Python. Dann habe ich versucht mit dem Code folgendePython: import _mysql ImportError: Kein Modul mit dem Namen '_mysql
import MySQLdb
db = MySQLdb.connect(host="localhost", # your host, usually localhost
user="root", # your username
passwd="", # your password
db="enb") # name of the data base
# you must create a Cursor object. It will let
# you execute all the queries you need
cur = db.cursor()
# Use all the SQL you like
cur.execute("SELECT * FROM pages")
# print all the first cell of all the rows
for row in cur.fetchall():
print (row[0])
db.close()
Aber ich habe Fehler
import MySQLdb
File "C:\Python34\lib\MySQLdb\__init__.py", line 19, in <module>
import _mysql
ImportError: No module named '_mysql'
Wie kann ich lösen this.I'm mit Windows 10.
pip install pymysql ist eine einfache Alternative. Hast du nur Tarball extrahiert? Denken Sie daran, dass Sie das Paket auch kompilieren müssen. Es hat einige C- oder C++ - Abhängigkeiten. –