ImportError: No module named MySQLdb

在运行python应用时

File "D:\myproject\testhzq\1\site-packages\flask\app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "D:\myproject\testhzq\1\site-packages\flask\app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "D:\myproject\testhzq\1\app\views.py", line 22, in index
    db.create_all()
  File "D:\myproject\testhzq\1\site-packages\flask_sqlalchemy\__init__.py", line 895, in create_all
    self._execute_for_all_tables(app, bind, 'create_all')
  File "D:\myproject\testhzq\1\site-packages\flask_sqlalchemy\__init__.py", line 887, in _execute_for_all_tables
    op(bind=self.get_engine(app, bind), **extra)
  File "D:\myproject\testhzq\1\site-packages\flask_sqlalchemy\__init__.py", line 833, in get_engine
    return connector.get_engine()
  File "D:\myproject\testhzq\1\site-packages\flask_sqlalchemy\__init__.py", line 499, in get_engine
    self._engine = rv = sqlalchemy.create_engine(info, **options)
  File "D:\myproject\testhzq\1\site-packages\sqlalchemy\engine\__init__.py", line 338, in create_engine
    return strategy.create(*args, **kwargs)
  File "D:\myproject\testhzq\1\site-packages\sqlalchemy\engine\strategies.py", line 64, in create
    dbapi = dialect_cls.dbapi(**dbapi_args)
  File "D:\myproject\testhzq\1\site-packages\sqlalchemy\connectors\mysqldb.py", line 52, in dbapi
    return __import__('MySQLdb')
ImportError: No module named MySQLdb

发现需要安装mysql-python
输入pip install mysql-python

但是安装不成功,‘Unable to find vcvarsall.bat’,需要安装VC++

Stack overflow (http://stackoverflow.com/questions/2272786/python-issueunable-to-find-vcvarsall-bat)上找到答案
这个是很多人遇到的问题,专门有人做了插件,根据所用的 win32 + python 2.7 现在对应的版本的插件,
第一次的安装,结果运行报错,‘——mysql’是1.2.4的而我安装的mysqldb是1.2.3
在这个网站(http://sourceforge.net/projects/mysql-python/?source=typ_redirect)找到合适的版本
因为python里面各种库,插件更新比较快,有可能没有现存的版本,那就需要弄清楚这个插件制作的原理,自己弄一个,
Stack overflow上面有链接,给了方法。


posted on 2014-12-02 09:59  雾中世界  阅读(2386)  评论(0编辑  收藏  举报

导航