我的代码在MacOS X上运行(10.12.5):
from sqlalchemy import create_engine
engine = create_engine('mysql+mysqldb://root@localhost:3306/blog')
print(engine)
问题:
File "database.py", line 3, in <module>
engine =create_engine('mysql+mysqldb://root@localhost:3306/louis')
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/sqlalchemy/engine/__init__.py", line 387, in create_engine
return strategy.create(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/sqlalchemy/engine/strategies.py", line 80, in create
dbapi = dialect_cls.dbapi(**dbapi_args
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 110, in dbapi
return __import__('MySQLdb')
ImportError: No module named 'MySQLdb'