使用flask-SQLalchemy提交sqlite3时出现导入错误

时间:2014-03-28 02:12:37

标签: python-2.7 sqlalchemy flask pycharm whoosh

很奇怪,我只是尝试使用flask-sqlalchemy更新sqlite3数据库中的值。

anime = Anime.query.get(2)
anime.finished=2
db.session.add(anime)
db.session.commit()

在提交之前一切正常,然后我得到了一个" ImportError:没有名为pycharm_re"的模块。

是的,我使用的是PyCharmCE IDE,但没有任何PyCharm基础导入。当我在终端中尝试这个时,导致了同样的错误。

最后,我发现它可能是关于嗖嗖 - 炼金术,我在models.py中有2个whoosh.whoosh_index(app,SomeClass)之前遇到过这个错误。

我在PyCharmCE中使用Python 2.7.3,在终端中使用2.7.5。系统是OS X 10.9.2。 整个错误日志:

Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/windrunner/bangumi/bangumi/views.py", line 76, in edit_anime
    db.session.commit()
  File "/Library/Python/2.7/site-packages/sqlalchemy/orm/scoping.py", line 149, in do
    return getattr(self.registry(), name)(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/sqlalchemy/orm/session.py", line 721, in commit
    self.transaction.commit()
  File "/Library/Python/2.7/site-packages/sqlalchemy/orm/session.py", line 361, in commit
    self.session.dispatch.after_commit(self.session)
  File "/Library/Python/2.7/site-packages/sqlalchemy/event.py", line 372, in __call__
    fn(*args, **kw)
  File "/Library/Python/2.7/site-packages/flask_sqlalchemy/__init__.py", line 170, in session_signal_after_commit
    models_committed.send(session.app, changes=d.values())
  File "/Library/Python/2.7/site-packages/blinker/base.py", line 267, in send
    for receiver in self.receivers_for(sender)]
  File "/Library/Python/2.7/site-packages/flask_whooshalchemy.py", line 242, in _after_flush
    index = whoosh_index(app, values[0][1].__class__)
  File "/Library/Python/2.7/site-packages/flask_whooshalchemy.py", line 168, in whoosh_index
    _create_index(app, model))
  File "/Library/Python/2.7/site-packages/flask_whooshalchemy.py", line 190, in _create_index
    if whoosh.index.exists_in(wi):
  File "/Library/Python/2.7/site-packages/whoosh/index.py", line 136, in exists_in
    ix = open_dir(dirname, indexname=indexname)
  File "/Library/Python/2.7/site-packages/whoosh/index.py", line 123, in open_dir
    return FileIndex(storage, schema=schema, indexname=indexname)
  File "/Library/Python/2.7/site-packages/whoosh/index.py", line 421, in __init__
    TOC.read(self.storage, self.indexname, schema=self._schema)
  File "/Library/Python/2.7/site-packages/whoosh/index.py", line 656, in read
    schema = pickle.loads(stream.read_string())
ImportError: No module named pycharm_re

0 个答案:

没有答案