No module named 'pydantic_core._pydantic_core'

I’m working on this script, but getting the error:

Traceback (most recent call last):
  File "/home/runner/MythEngine/", line 2, in <module>
    import litellm
  File "/home/runner/MythEngine/.pythonlibs/lib/python3.10/site-packages/litellm/", line 369, in <module>
    from .timeout import timeout
  File "/home/runner/MythEngine/.pythonlibs/lib/python3.10/site-packages/litellm/", line 20, in <module>
    from litellm.exceptions import Timeout
  File "/home/runner/MythEngine/.pythonlibs/lib/python3.10/site-packages/litellm/", line 12, in <module>
    from openai import (
  File "/home/runner/MythEngine/.pythonlibs/lib/python3.10/site-packages/openai/", line 8, in <module>
    from . import types
  File "/home/runner/MythEngine/.pythonlibs/lib/python3.10/site-packages/openai/types/", line 5, in <module>
    from .edit import Edit as Edit
  File "/home/runner/MythEngine/.pythonlibs/lib/python3.10/site-packages/openai/types/", line 6, in <module>
    from .._models import BaseModel
  File "/home/runner/MythEngine/.pythonlibs/lib/python3.10/site-packages/openai/", line 20, in <module>
    from pydantic.fields import FieldInfo
  File "/home/runner/MythEngine/.pythonlibs/lib/python3.10/site-packages/pydantic/", line 21, in <module>
    from pydantic_core import PydanticUndefined
  File "/home/runner/MythEngine/.pythonlibs/lib/python3.10/site-packages/pydantic_core/", line 6, in <module>
    from ._pydantic_core import (
ModuleNotFoundError: No module named 'pydantic_core._pydantic_core'

Does this look like an error in the litellm library or a problem with Replit? I’ve used Litellm a lot before on a different Repl without this error. Pydantic (and pydantic_core) are both installed.

import os
import litellm
from litellm import completion


def rewrite_text(text):
        response = completion(
                {"role": "system", "content": "Rewrite the following story in under 300 tokens "},
                {"role": "user", "content": text}
        return response.choices[0].message['content']
    except Exception as e:
        print(f"Error during OpenAI API call: {e}")
        return None

def process_markdown_files(folder_path):
    Process all markdown files in the given folder.
    for filename in os.listdir(folder_path):
        if filename.endswith('.md'):
            file_path = os.path.join(folder_path, filename)
            with open(file_path, 'r', encoding='utf-8') as file:
                content =
                rewritten_content = rewrite_text(content)
                if rewritten_content:
                    # Process the rewritten content as needed
                    print(f"Rewritten content for {filename}:\n{rewritten_content}\n")

# Path to the folder containing markdown files
folder_path = 'stories'

This honestly seems more like a litellm issue to me rather than a Replit issue.
You could try kill 1ing [1] the Repl, or if possible, delete this Repl and move to another.

  1. Running kill 1 in the Shell. ↩︎