AlaGrine / RAG_chatabot_with_Langchain

A retrieval augmented generation chatbot 🤖 powered by 🔗 Langchain, Cohere, OpenAI, Google Generative AI and Hugging Face 🤗
23 stars 22 forks source link

Problem to start streamlit app on Mac #2

Open lshaigorodsky-wbgmames opened 2 months ago

lshaigorodsky-wbgmames commented 2 months ago

Thank you for great code example and blog post!

Following the steps described in the README file (after installing all packages and running source langchain_env/bin/activate

When I start the app with streamlit run RAG_app.py

I almost immediately get following error

You can now view your Streamlit app in your browser.

  Local URL: http://localhost:8501
  Network URL: http://10.85.22.247:8501

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow should only be instantiated on the main thread!'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000018da088c0 __exceptionPreprocess + 176
    1   libobjc.A.dylib                     0x000000018d501eb4 objc_exception_throw + 60
    2   CoreFoundation                      0x000000018da2dbac _CFBundleGetValueForInfoKey + 0
    3   AppKit                              0x000000019117d874 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 188
    4   AppKit                              0x000000019117d7ac -[NSWindow initWithContentRect:styleMask:backing:defer:] + 48
    5   libtk8.6.dylib                      0x00000001688e1d48 TkMacOSXMakeRealWindowExist + 572
    6   libtk8.6.dylib                      0x00000001688e1998 TkWmMapWindow + 60
    7   libtk8.6.dylib                      0x0000000168839410 Tk_MapWindow + 148
    8   libtk8.6.dylib                      0x0000000168841e68 MapFrame + 76
    9   libtcl8.6.dylib                     0x0000000168c0b178 TclServiceIdle + 72
    10  libtcl8.6.dylib                     0x0000000168bec514 Tcl_DoOneEvent + 120
    11  libtk8.6.dylib                      0x00000001688d3360 TkpInit + 800
    12  libtk8.6.dylib                      0x000000016883a8fc Initialize + 2356
    13  _tkinter.cpython-312-darwin.so      0x000000014e206390 Tcl_AppInit + 92
    14  _tkinter.cpython-312-darwin.so      0x000000014e201404 Tkapp_New + 548
    15  _tkinter.cpython-312-darwin.so      0x000000014e2011dc _tkinter_create_impl + 268
    16  _tkinter.cpython-312-darwin.so      0x000000014e200cb4 _tkinter_create + 236
    17  Python                              0x0000000105c4b774 cfunction_vectorcall_FASTCALL + 96
    18  Python                              0x0000000105d4e28c _PyEval_EvalFrameDefault + 47356
    19  Python                              0x0000000105bdcc50 _PyObject_FastCallDictTstate + 96
    20  Python                              0x0000000105c79d3c slot_tp_init + 208
    21  Python                              0x0000000105c6f008 type_call + 148
    22  Python                              0x0000000105bdcecc _PyObject_MakeTpCall + 128
    23  Python                              0x0000000105d4e3f0 _PyEval_EvalFrameDefault + 47712
    24  Python                              0x0000000105d42678 PyEval_EvalCode + 304
    25  Python                              0x0000000105d3e0cc builtin_exec + 472
    26  Python                              0x0000000105c4b87c cfunction_vectorcall_FASTCALL_KEYWORDS + 92
    27  Python                              0x0000000105d4e28c _PyEval_EvalFrameDefault + 47356
    28  Python                              0x0000000105be0fdc method_vectorcall + 368
    29  Python                              0x0000000105d50204 _PyEval_EvalFrameDefault + 55412
    30  Python                              0x0000000105be0fdc method_vectorcall + 368
    31  Python                              0x0000000105e65a84 thread_run + 92
    32  Python                              0x0000000105dd78fc pythread_wrapper + 48
    33  libsystem_pthread.dylib             0x000000018d8b7034 _pthread_start + 136
    34  libsystem_pthread.dylib             0x000000018d8b1e3c thread_start + 8
)
libc++abi: terminating due to uncaught exception of type NSException
zsh: abort      streamlit run RAG_app.py
Avi-141 commented 1 month ago

NSWindow is an issue due to usage of tkinter on MacOs. You will need to work around that, and remove all usages of Tkinter.

sumedha73 commented 4 weeks ago

I am facing the same issue. I have created a venv and installed only the requirements…how is tkinter still an issue?

Avi-141 commented 4 weeks ago

I am facing the same issue. I have created a venv and installed only the requirements…how is tkinter still an issue?

On MacOS the GUI is facing an issue, its about a forked thread I think, based on the error: 'NSWindow should only be instantiated on the main thread!'.

Also, note that You can’t use Swing with lwjgl3 on OSX. As far as I know, there isn’t a way around that still. In the code, using Tkinter inherently does this, due to peer dependencies.

I tried removing the usage of Tkinter and root. The UI spun up, i could upload custom documents and tried creating embeddings But no luck. Still gives me some errors.

sumedha73 commented 4 weeks ago

I am facing the same issue. I have created a venv and installed only the requirements…how is tkinter still an issue?

On MacOS the GUI is facing an issue, its about a forked thread I think, based on the error: 'NSWindow should only be instantiated on the main thread!'.

Also, note that You can’t use Swing with lwjgl3 on OSX. As far as I know, there isn’t a way around that still. In the code, using Tkinter inherently does this, due to peer dependencies.

I tried removing the usage of Tkinter and root. The UI spun up, i could upload custom documents and tried creating embeddings But no luck. Still gives me some errors.

Ohh okayy thanks for the insight!! I’ll try to run it on a windows os, hopefully it’ll work