首页 > 代码库 > ImportError: No module named MySQLdb
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上面有链接,给了方法。
ImportError: No module named MySQLdb
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。