我尝试安装用于 Eclipse/Pydev 的 Python 3.2 的 SQLAlchemy。一个简单的测试脚本失败
from sqlalchemy.engine import create_engine
engine=create_engine("mysql://user:password@server/database")
如果我从 Eclipse 运行它,我会得到
Traceback (most recent call last):
File "...\sqlalchemy.py", line 1, in <module>
from sqlalchemy.engine import create_engine
File "...\sqlalchemy.py", line 1, in <module>
from sqlalchemy.engine import create_engine
ImportError: No module named engine
但是我实际上是用 Ctrl-Shirt-O 生成了导入行,所以 Eclipse 自动发现并知道它。Pydev 也没有在脚本中显示任何错误。
如果我在交互式 Pydev 控制台中尝试相同的脚本,我会得到
from sqlalchemy.engine import create_engine
engine=create_engine("mysql://user:password@server/database")
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Python32\lib\site-packages\sqlalchemy-0.7.8-py3.2.egg\sqlalchemy\engine \__init__.py", line 338, in create_engine
return strategy.create(*args, **kwargs)
File "C:\Python32\lib\site-packages\sqlalchemy-0.7.8-py3.2.egg\sqlalchemy\engine\strategies.py", line 64, in create
dbapi = dialect_cls.dbapi(**dbapi_args)
File "C:\Python32\lib\site-packages\sqlalchemy-0.7.8-py3.2.egg\sqlalchemy\connectors\mysqldb.py", line 52, in dbapi
return __import__('MySQLdb')
ImportError: No module named MySQLdb
你知道如何让它工作吗?