SciPhi-AI / R2R

The Elasticsearch for RAG. Build, scale, and deploy state of the art Retrieval-Augmented Generation applications
https://r2r-docs.sciphi.ai/
MIT License
3.26k stars 237 forks source link

No module named 'pydantic_core._pydantic_core' #305

Open jamesfishwick opened 5 months ago

jamesfishwick commented 5 months ago

Describe the bug When I use Python3 (Python 3.12.3) as installed by homebrew on my Mac, the python -m r2r.examples.servers.basic_pipeline --config local_ollama command errors out with:

File "/Users/user/rag2riches/pydantic/main.py", line 12, in <module>
    import pydantic_core
  File "/Users/user/rag2riches/pydantic_core/__init__.py", line 6, in <module>
    from ._pydantic_core import (
ModuleNotFoundError: No module named 'pydantic_core._pydantic_core'

but I have pydantic_core on my machine:

pip show pydantic_core
Name: pydantic_core
Version: 2.16.3
Summary: 
Home-page: https://github.com/pydantic/pydantic-core
Author: 
Author-email: Samuel Colvin <s@muelcolvin.com>
License: MIT
Location: /Users/user/.local/lib/python/site-packages
Requires: typing-extensions
Required-by: pydantic

Expected behavior The server runs.

Desktop (please complete the following information):

Additional context This was working running from the native OSX python instance, but LibreSSL was causing errors when I was trying to run https://github.com/SciPhi-AI/SciPhi-Demo, so I switched to a proper install of python. This error occurs whether or not I use a virtual environment.

emrgnt-cmplxty commented 5 months ago

This is strange, is this an error due to the version of pydantic?

I will try to replicate so that we can diagnose and fix - any additional information or attempts at solving would be helpful for us to pin down why this is occurring.

jamesfishwick commented 5 months ago

fwiw

Here's the whole error:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/user/rag2riches/venv/lib/python3.12/site-packages/r2r/examples/servers/basic_pipeline.py", line 6, in <module>
    from r2r.main import E2EPipelineFactory, R2RConfig
  File "/Users/user/rag2riches/venv/lib/python3.12/site-packages/r2r/main/__init__.py", line 1, in <module>
    from .app import create_app
  File "/Users/user/rag2riches/venv/lib/python3.12/site-packages/r2r/main/app.py", line 7, in <module>
    from fastapi import (
  File "/Users/user/rag2riches/venv/lib/python3.12/site-packages/fastapi/__init__.py", line 7, in <module>
    from .applications import FastAPI as FastAPI
  File "/Users/user/rag2riches/venv/lib/python3.12/site-packages/fastapi/applications.py", line 16, in <module>
    from fastapi import routing
  File "/Users/user/rag2riches/venv/lib/python3.12/site-packages/fastapi/routing.py", line 22, in <module>
    from fastapi import params
  File "/Users/user/rag2riches/venv/lib/python3.12/site-packages/fastapi/params.py", line 5, in <module>
    from fastapi.openapi.models import Example
  File "/Users/user/rag2riches/venv/lib/python3.12/site-packages/fastapi/openapi/models.py", line 4, in <module>
    from fastapi._compat import (
  File "/Users/user/rag2riches/venv/lib/python3.12/site-packages/fastapi/_compat.py", line 20, in <module>
    from fastapi.exceptions import RequestErrorModel
  File "/Users/user/rag2riches/venv/lib/python3.12/site-packages/fastapi/exceptions.py", line 3, in <module>
    from pydantic import BaseModel, create_model
  File "/Users/user/rag2riches/pydantic/__init__.py", line 389, in __getattr__
    module = import_module(module_name, package=package)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.12/3.12.3/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 "/Users/user/rag2riches/pydantic/main.py", line 12, in <module>
    import pydantic_core
  File "/Users/user/rag2riches/pydantic_core/__init__.py", line 6, in <module>
    from ._pydantic_core import (
ModuleNotFoundError: No module named 'pydantic_core._pydantic_core'
jamesfishwick commented 5 months ago

Most of the Google results for this issue bring up folks who are having trouble getting suitable packages built for a specific architecture https://stackoverflow.com/questions/76650856/no-module-named-pydantic-core-pydantic-core-in-aws-lambda-though-library-is-i

for me I see: