AttributeError: 'super' object has no attribute 'parse_obj'

Hi all,

I got the above error in lesson 5 when trying to run this line:

spec = OpenAPISpec.from_text(text)

Just wondering if there is a way to solve?


Hi Martin, yes I solved this error by installing one more package and fixing the versions to the same as run on the hosted Cloudera notebook.

First check that the same pydantic and langchain versions are installed locally as when running the notebook on the Coursera hosted notebook-platform.

The requirements are,


I found that other had solved the above error by also installing the openapi-schema-pydantic package. The version I’ve used for running the notebook locally is,

1 Like

I have installed the specific version of pydantic, langchain and openai-schema-pydantic. But the error still persists.

Thanks, installing openapi-schema-pydantic==1.2.4 works for me!

Is it you running the code through a local notebook?

Could you check that you are running your correct kernel in your notebook, and check that the versions that are executed have the same versions as specified in the thread. You can check the versions through these commands.

import langchain
import pydantic

Hi Adam, Thank you for your response. I used Google Colab. Here is the langchain and pydantic version that I installed: !pip install pydantic==1.10.8
!pip install langchain==0.0.312

OK, on Colab I have not tested. Try adding this too,

!pip install openapi-schema-pydantic==1.2.4

Hi Adam, It’s work now. Thannk you.

Thanks Adam!

1. My Versons:
On my laptop, I installed openapi_schema_pydantic (1.2.4). Now I have

langchain 0.0.353
langchain-cli 0.0.21
langchain-community 0.0.16
langchain-core 0.1.16
langchain-openai 0.0.5
langchainhub 0.1.14
pydantic 2.6.2
pydantic_core 2.16.3
openapi-schema-pydantic 1.2.4

2. My Code:
Added openapi_schema_pydantic import compared to Instructor’s code, as learnt from above posts, and

from langchain.chains.openai_functions.openapi import openapi_spec_to_openai_fn
from langchain.utilities.openapi import OpenAPISpec
from openapi_schema_pydantic import OpenAPI, Info, PathItem, Operation, Response ← added this
text = “”"

spec = OpenAPISpec.from_text(text)

3. My Error:
Instructor code did not err, but mine did. Different error message compared to others in this post.

PydanticUserError: const is removed, use Literal instead
For further information visit Redirecting...

What am I missing, especially when the same code seems to be working for others? How do I overcome the error?

1. Got it: Ref: AttributeError: 'super' object has no attribute 'parse_obj' when using OpenAPISpec.from_file · Issue #9520 · langchain-ai/langchain · GitHub which says:

openapi_schema_pydantic is changed to:
openapi-pydantic 0.3.2 (last version)
install it when using langchain

2. Refresh/Restart: I installed both openapi_schema_pydantic and openapi-pydantic. So, I retarted my VSCode in my laptop.

3. My Code: made some changes to my code. Imported from openapi-pydantic instead of openapi_schema_pydantic. That worked!

from langchain.chains.openai_functions.openapi import openapi_spec_to_openai_fn
from langchain.utilities.openapi import OpenAPISpec
from openapi_pydantic import OpenAPI, Info, PathItem, Operation, Response ← modified this, from: openapi_schema_pydantic to: openapi_pydantic
text = “”"

spec = OpenAPISpec.from_text(text)

4. Lesson learnt: start afresh when some libraries are included in others :slight_smile: