severian42 / GraphRAG-Local-UI

GraphRAG using Local LLMs - Features robust API and multiple apps for Indexing/Prompt Tuning/Query/Chat/Visualizing/Etc. This is meant to be the ultimate GraphRAG/KG local LLM app.
MIT License
1.78k stars 211 forks source link

bug: ModuleNotFoundError: No module named 'distutils' #1

Closed sammcj closed 4 months ago

sammcj commented 4 months ago

Really neat looking project!

I went to try it out and hit the following error when trying to run gradio:

Traceback (most recent call last):
  File "/Users/samm/git/GraphRAG-Ollama-UI/.venv/bin/gradio", line 5, in <module>
    from gradio.reload import run_in_reload_mode
  File "/Users/samm/git/GraphRAG-Ollama-UI/.venv/lib/python3.12/site-packages/gradio/__init__.py", line 3, in <module>
    import gradio.components as components
  File "/Users/samm/git/GraphRAG-Ollama-UI/.venv/lib/python3.12/site-packages/gradio/components.py", line 34, in <module>
    from gradio import media_data, processing_utils, utils
  File "/Users/samm/git/GraphRAG-Ollama-UI/.venv/lib/python3.12/site-packages/gradio/processing_utils.py", line 23, in <module>
    from gradio import encryptor, utils
  File "/Users/samm/git/GraphRAG-Ollama-UI/.venv/lib/python3.12/site-packages/gradio/utils.py", line 20, in <module>
    from distutils.version import StrictVersion
ModuleNotFoundError: No module named 'distutils'
sammcj commented 4 months ago

Ah, it looks like your requirements.txt is missing setuptools, after installing setuptools gradio states it's launched but throws an error:


Launching in *reload mode* on: http://127.0.0.1:7860 (Press CTRL+C to quit)

Watching: '/Users/samm/git/GraphRAG-Ollama-UI/.venv/lib/python3.12/site-packages/gradio', '/Users/samm/git/GraphRAG-Ollama-UI'

Process SpawnProcess-1:
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/samm/git/GraphRAG-Ollama-UI/.venv/lib/python3.12/site-packages/uvicorn/_subprocess.py", line 80, in subprocess_started
    target(sockets=sockets)
  File "/Users/samm/git/GraphRAG-Ollama-UI/.venv/lib/python3.12/site-packages/uvicorn/server.py", line 65, in run
    return asyncio.run(self.serve(sockets=sockets))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
  File "/Users/samm/git/GraphRAG-Ollama-UI/.venv/lib/python3.12/site-packages/uvicorn/server.py", line 69, in serve
    await self._serve(sockets)
  File "/Users/samm/git/GraphRAG-Ollama-UI/.venv/lib/python3.12/site-packages/uvicorn/server.py", line 76, in _serve
    config.load()
  File "/Users/samm/git/GraphRAG-Ollama-UI/.venv/lib/python3.12/site-packages/uvicorn/config.py", line 434, in load
    self.loaded_app = import_from_string(self.app)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/samm/git/GraphRAG-Ollama-UI/.venv/lib/python3.12/site-packages/uvicorn/importer.py", line 19, in import_from_string
    module = importlib.import_module(module_str)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/Users/samm/git/GraphRAG-Ollama-UI/app.py", line 624, in <module>
    with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
                                         ^^^^^^^^^
AttributeError: module 'gradio' has no attribute 'themes'
sammcj commented 4 months ago

Downgrading gradio to a really old version (gradio==3.41.2) works around the problem but that doesn't seem quite right 🤔

severian42 commented 4 months ago

Hey!! Thanks for checking this out and raising the issue! The easiest way to avoid the distuls error is to use the latest Gradio version and launch the app with 'python app.py' instead of 'gradio app.py'. For some reason the reload and watch feature that comes with using the gradio flag instead of python for launching can not work do to the conda env. I usually run it with gradio app.py while development but it will work perfectly fine when launched the traditional python way

Hope that helps solve the issue! Everything should be pretty straightforward since it's the Microsoft graphrag repo with the extra gradio UI layered on top. Let me know if you're still encountering issues

sammcj commented 4 months ago

Oh that's interesting, thanks for your response, nice work on the app!