Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

import langchain => Error : TypeError: issubclass() arg 1 must be a class

I want to use langchain for my project.

so I installed it using following command : pip install langchain

but While importing "langchain" I am facing following Error:

File /usr/lib/python3.8/typing.py:774, in _GenericAlias.__subclasscheck__(self, cls)
    772 if self._special:
    773     if not isinstance(cls, _GenericAlias):
--> 774         return issubclass(cls, self.__origin__)
    775     if cls._special:
    776         return issubclass(cls.__origin__, self.__origin__)

TypeError: issubclass() arg 1 must be a class

Any one who can solve this error ?

like image 350
M. D. P Avatar asked Aug 31 '25 16:08

M. D. P


1 Answers

So I was trying it for hours and at last I found a solution hope it helps you.

First, I did this:

pip install typing-inspect==0.8.0 typing_extensions==4.5.0

Then:

pip install pydantic -U

After this will throw an error but once again I did:

pip install pydantic==1.10.11

Then it started working.

like image 189
Smit Trivedi Avatar answered Sep 02 '25 05:09

Smit Trivedi