Having issues importing the library #4487
Closed
sohanasarah
started this conversation in
General
Replies: 2 comments 2 replies
-
@sohanasarah would you mind running |
Beta Was this translation helpful? Give feedback.
0 replies
-
have you found any solution? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have this error message while trying to import any module (e.g from haystack.document_stores import InMemoryDocumentStore). I was unable to run the model before.
The error message is:
RuntimeError Traceback (most recent call last)
Cell In [4], line 1
----> 1 from haystack.document_stores import InMemoryDocumentStore
3 document_store = InMemoryDocumentStore(use_bm25=True)
File C:\Program Files\python\lib\site-packages\haystack_init_.py:1
----> 1 from haystack.retriever.tfidf import TfidfRetriever
2 from haystack.reader.farm import FARMReader
3 from haystack.database import db
File C:\Program Files\python\lib\site-packages\haystack\retriever\tfidf.py:7
4 import pandas as pd
5 from sklearn.feature_extraction.text import TfidfVectorizer
----> 7 from haystack.database import db
8 from haystack.database.orm import Document
10 logger = logging.getLogger(name)
File C:\Program Files\python\lib\site-packages\haystack\database_init_.py:28
26 app.config["SQLALCHEMY_DATABASE_URI"] = f"{DATABASE_URL}"
27 db = SQLAlchemy(app)
---> 28 db.create_all()
File ~\AppData\Roaming\Python\Python310\site-packages\flask_sqlalchemy\extension.py:884, in SQLAlchemy.create_all(self, bind_key)
867 def create_all(self, bind_key: str | None | list[str | None] = "all") -> None:
868 """Create tables that do not exist in the database by calling
869
metadata.create_all()
for all or some bind keys. This does not870 update existing tables, use a migration library for that.
(...)
882 Added the
bind
andapp
parameters.883 """
--> 884 self._call_for_binds(bind_key, "create_all")
File ~\AppData\Roaming\Python\Python310\site-packages\flask_sqlalchemy\extension.py:855, in SQLAlchemy._call_for_binds(self, bind_key, op_name)
853 for key in keys:
854 try:
--> 855 engine = self.engines[key]
856 except KeyError:
857 message = f"Bind key '{key}' is not in 'SQLALCHEMY_BINDS' config."
File ~\AppData\Roaming\Python\Python310\site-packages\flask_sqlalchemy\extension.py:636, in SQLAlchemy.engines(self)
623 @Property
624 def engines(self) -> t.Mapping[str | None, sa.engine.Engine]:
625 """Map of bind keys to :class:
sqlalchemy.engine.Engine
instances for current626 application. The
None
key refers to the default engine, and is available as627 :attr:
engine
.(...)
634 .. versionadded:: 3.0
635 """
--> 636 app = current_app._get_current_object() # type: ignore[attr-defined]
638 if app not in self._app_engines:
639 raise RuntimeError(
640 "The current Flask app is not registered with this 'SQLAlchemy'"
641 " instance. Did you forget to call 'init_app', or did you create"
642 " multiple 'SQLAlchemy' instances?"
643 )
File C:\Program Files\python\lib\site-packages\werkzeug\local.py:513, in LocalProxy.init.._get_current_object()
511 obj = local.get() # type: ignore[union-attr]
512 except LookupError:
--> 513 raise RuntimeError(unbound_message) from None
515 return get_name(obj)
RuntimeError: Working outside of application context.
This typically means that you attempted to use functionality that needed
the current application. To solve this, set up an application context
with app.app_context(). See the documentation for more information.
Beta Was this translation helpful? Give feedback.
All reactions