LlamaParse -- Import Error: cannot import name 'Secret' from 'pydantic' #469

Closed
opened 2026-02-16 00:17:56 -05:00 by yindo · 3 comments
Owner

Originally created by @devluist on GitHub (May 7, 2025).

Describe the bug
After I installed the package and set the api key, I cannot run the project. I am using Django Rest Framework, when I try to start the server the issue close the connection and stops the server. Is conflicting with Pydantic according to the error

Client:

  • Python Library
    LlamaParse

Additional context
I am using a Free account, but the issue I think is unrelated to the cloud service since it does not allow to start.

I am using the LlamaParse in the code,
Python 3.11.2
pip 25.1.1
pydantic 2.4.2
pydantic_core 2.10.1

pip install llama-cloud-services brought this 3 :

llama-cloud==0.1.19
llama-cloud-services==0.6.21
llama-index-core==0.11.2

This is part of the code (with only this and the rest commented out, the server stops)

@shared_task
def process_document_with_llamaparse(document_id):
        try:
              document = Document.objects.get(id=document_id)
              parser = LlamaParse(api_key="MYKEY")
      
              # Process the document
              result = parser.parse(document.file.path)
        except Exception as e:
                logger.error(f"Error processing document {document_id}: {str(e)}")

this is the error when I try to run the django server

from llama_cloud_services import LlamaParse
File "/home/user/.local/lib/python3.11/site-packages/llama_cloud_services/__init__.py", line 1, in <module>
  from llama_cloud_services.parse import LlamaParse
File "/home/user/.local/lib/python3.11/site-packages/llama_cloud_services/parse/__init__.py", line 1, in <module>
  from llama_cloud_services.parse.base import (
File "/home/user/.local/lib/python3.11/site-packages/llama_cloud_services/parse/base.py", line 15, in <module>
  from llama_index.core.async_utils import asyncio_run, run_jobs
File "/home/user/.local/lib/python3.11/site-packages/llama_index/core/__init__.py", line 10, in <module>
  from llama_index.core.base.response.schema import Response
File "/home/user/.local/lib/python3.11/site-packages/llama_index/core/base/response/schema.py", line 7, in <module>
  from llama_index.core.async_utils import asyncio_run
File "/home/user/.local/lib/python3.11/site-packages/llama_index/core/async_utils.py", line 7, in <module>
  import llama_index.core.instrumentation as instrument
File "/home/user/.local/lib/python3.11/site-packages/llama_index/core/instrumentation/__init__.py", line 5, in <module>
  from llama_index.core.instrumentation.dispatcher import (
File "/home/user/.local/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 7, in <module>
  from llama_index.core.bridge.pydantic import BaseModel, Field, ConfigDict
File "/home/user/.local/lib/python3.11/site-packages/llama_index/core/bridge/pydantic.py", line 2, in <module>
  from pydantic import (
ImportError: cannot import name 'Secret' from 'pydantic' (/home/user/.local/lib/python3.11/site-packages/pydantic/__init__.py)
Originally created by @devluist on GitHub (May 7, 2025). **Describe the bug** After I installed the package and set the api key, I cannot run the project. I am using Django Rest Framework, when I try to start the server the issue close the connection and stops the server. Is conflicting with Pydantic according to the error **Client:** - Python Library LlamaParse **Additional context** I am using a Free account, but the issue I think is unrelated to the cloud service since it does not allow to start. I am using the LlamaParse in the code, Python 3.11.2 pip 25.1.1 pydantic 2.4.2 pydantic_core 2.10.1 `pip install llama-cloud-services` brought this 3 : ```bash llama-cloud==0.1.19 llama-cloud-services==0.6.21 llama-index-core==0.11.2 ``` This is part of the code (with only this and the rest commented out, the server stops) ``` @shared_task def process_document_with_llamaparse(document_id): try: document = Document.objects.get(id=document_id) parser = LlamaParse(api_key="MYKEY") # Process the document result = parser.parse(document.file.path) except Exception as e: logger.error(f"Error processing document {document_id}: {str(e)}") ``` this is the error when I try to run the django server ```bash from llama_cloud_services import LlamaParse File "/home/user/.local/lib/python3.11/site-packages/llama_cloud_services/__init__.py", line 1, in <module> from llama_cloud_services.parse import LlamaParse File "/home/user/.local/lib/python3.11/site-packages/llama_cloud_services/parse/__init__.py", line 1, in <module> from llama_cloud_services.parse.base import ( File "/home/user/.local/lib/python3.11/site-packages/llama_cloud_services/parse/base.py", line 15, in <module> from llama_index.core.async_utils import asyncio_run, run_jobs File "/home/user/.local/lib/python3.11/site-packages/llama_index/core/__init__.py", line 10, in <module> from llama_index.core.base.response.schema import Response File "/home/user/.local/lib/python3.11/site-packages/llama_index/core/base/response/schema.py", line 7, in <module> from llama_index.core.async_utils import asyncio_run File "/home/user/.local/lib/python3.11/site-packages/llama_index/core/async_utils.py", line 7, in <module> import llama_index.core.instrumentation as instrument File "/home/user/.local/lib/python3.11/site-packages/llama_index/core/instrumentation/__init__.py", line 5, in <module> from llama_index.core.instrumentation.dispatcher import ( File "/home/user/.local/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 7, in <module> from llama_index.core.bridge.pydantic import BaseModel, Field, ConfigDict File "/home/user/.local/lib/python3.11/site-packages/llama_index/core/bridge/pydantic.py", line 2, in <module> from pydantic import ( ImportError: cannot import name 'Secret' from 'pydantic' (/home/user/.local/lib/python3.11/site-packages/pydantic/__init__.py) ```
yindo added the bug label 2026-02-16 00:17:56 -05:00
yindo closed this issue 2026-02-16 00:17:56 -05:00
Author
Owner

@logan-markewich commented on GitHub (May 7, 2025):

@devluist your pydantic version is pretty old, the latest is v2.11.4.

v2.4.2 came out Sept 2023(!)

Can you try updating?

@logan-markewich commented on GitHub (May 7, 2025): @devluist your pydantic version is pretty old, the latest is v2.11.4. v2.4.2 came out Sept 2023(!) Can you try updating?
Author
Owner

@logan-markewich commented on GitHub (May 7, 2025):

Your llama-index-core version is also quite old, we should update the minimum dep here

@logan-markewich commented on GitHub (May 7, 2025): Your `llama-index-core` version is also quite old, we should update the minimum dep here
Author
Owner

@devluist commented on GitHub (May 8, 2025):

oh yeah, you are right, by upgrading to that version it did solve the issue
I had another dependency that it was pushing pydantic to that lower version, I upgraded both and the issue of

ImportError: cannot import name 'Secret' from 'pydantic'

is fixed, thank you for your fast response

@devluist commented on GitHub (May 8, 2025): oh yeah, you are right, by upgrading to that version it did solve the issue I had another dependency that it was pushing pydantic to that lower version, I upgraded both and the issue of ```ImportError: cannot import name 'Secret' from 'pydantic'``` is fixed, thank you for your fast response
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: run-llama/llama_cloud_services#469