-
Notifications
You must be signed in to change notification settings - Fork 16.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import langchain with python<=3.9 fails #5113
Comments
Even with 3.10 though the import works, once you try using the module you will encounter this error |
Running in to this for python v3.8 and v3.9 I suspect some package that has not been pinned has been updated in the past few hours on pypi |
I get the same error on py3.9 too. |
Does anyone know the instruction page of supported python versions? |
The pypi says ">Python >=3.8.1, <4.0 " |
Fix version of these dependence:
Solve the issue for me: |
It worked! Thank you! typing_extensions was updated only a few hours ago and it seems to have caused something. |
Could the poetry.lock please be updated to actually lock breaking dependencies? |
I encountered the same error while using langchain on Docker. Here's my Dockerfile: FROM python:3.8-slim
# I also tried python:3.8, python:3.8-buster, python:3.9-slim and didn't work.
# pyton:3.10-slim works for me. I didn't face this issue on my local Ubuntu as below with python-3.8. NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal I modified requirements.txt by changing $ sudo docker-compose run web bash
root@5bf0c69be9ec:/app# python --version
Python 3.8.16
root@5bf0c69be9ec:/app# python
Python 3.8.16 (default, May 3 2023, 10:09:08)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import langchain
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.8/site-packages/langchain/__init__.py", line 6, in <module>
from langchain.agents import MRKLChain, ReActChain, SelfAskWithSearchChain
File "/usr/local/lib/python3.8/site-packages/langchain/agents/__init__.py", line 2, in <module>
from langchain.agents.agent import (
File "/usr/local/lib/python3.8/site-packages/langchain/agents/agent.py", line 16, in <module>
from langchain.agents.tools import InvalidTool
File "/usr/local/lib/python3.8/site-packages/langchain/agents/tools.py", line 8, in <module>
from langchain.tools.base import BaseTool, Tool, tool
File "/usr/local/lib/python3.8/site-packages/langchain/tools/__init__.py", line 42, in <module>
from langchain.tools.vectorstore.tool import (
File "/usr/local/lib/python3.8/site-packages/langchain/tools/vectorstore/tool.py", line 13, in <module>
from langchain.chains import RetrievalQA, RetrievalQAWithSourcesChain
File "/usr/local/lib/python3.8/site-packages/langchain/chains/__init__.py", line 2, in <module>
from langchain.chains.api.base import APIChain
File "/usr/local/lib/python3.8/site-packages/langchain/chains/api/base.py", line 13, in <module>
from langchain.chains.api.prompt import API_RESPONSE_PROMPT, API_URL_PROMPT
File "/usr/local/lib/python3.8/site-packages/langchain/chains/api/prompt.py", line 2, in <module>
from langchain.prompts.prompt import PromptTemplate
File "/usr/local/lib/python3.8/site-packages/langchain/prompts/__init__.py", line 3, in <module>
from langchain.prompts.chat import (
File "/usr/local/lib/python3.8/site-packages/langchain/prompts/chat.py", line 10, in <module>
from langchain.memory.buffer import get_buffer_string
File "/usr/local/lib/python3.8/site-packages/langchain/memory/__init__.py", line 28, in <module>
from langchain.memory.vectorstore import VectorStoreRetrieverMemory
File "/usr/local/lib/python3.8/site-packages/langchain/memory/vectorstore.py", line 10, in <module>
from langchain.vectorstores.base import VectorStoreRetriever
File "/usr/local/lib/python3.8/site-packages/langchain/vectorstores/__init__.py", line 2, in <module>
from langchain.vectorstores.analyticdb import AnalyticDB
File "/usr/local/lib/python3.8/site-packages/langchain/vectorstores/analyticdb.py", line 15, in <module>
from langchain.embeddings.base import Embeddings
File "/usr/local/lib/python3.8/site-packages/langchain/embeddings/__init__.py", line 19, in <module>
from langchain.embeddings.openai import OpenAIEmbeddings
File "/usr/local/lib/python3.8/site-packages/langchain/embeddings/openai.py", line 67, in <module>
class OpenAIEmbeddings(BaseModel, Embeddings):
File "pydantic/main.py", line 197, in pydantic.main.ModelMetaclass.__new__
File "pydantic/fields.py", line 506, in pydantic.fields.ModelField.infer
File "pydantic/fields.py", line 436, in pydantic.fields.ModelField.__init__
File "pydantic/fields.py", line 552, in pydantic.fields.ModelField.prepare
File "pydantic/fields.py", line 663, in pydantic.fields.ModelField._type_analysis
File "pydantic/fields.py", line 808, in pydantic.fields.ModelField._create_sub_type
File "pydantic/fields.py", line 436, in pydantic.fields.ModelField.__init__
File "pydantic/fields.py", line 552, in pydantic.fields.ModelField.prepare
File "pydantic/fields.py", line 668, in pydantic.fields.ModelField._type_analysis
File "/usr/local/lib/python3.8/typing.py", line 774, in __subclasscheck__
return issubclass(cls, self.__origin__)
TypeError: issubclass() arg 1 must be a class
>>> |
In Dockerfile, FROM python:3.10-slim is ok for me. |
Spent hours debugging this. Glad I found this thread. python:3.10-slim worked for me. Thanks @tiensunguyen |
TY - I thought I was losing my mind. Was working on my laptop but not my GCP instance. This fixed it. |
BTW it also fails with
|
Hmm it's not working for me. I had tried to uninstall both packages and langchain and then reinstall them as well. Any other pointers? |
My older docker images which were created before this build are working. But nothing since this build. Is there a solution which is working? |
Hi, This fix doesn't work for me python =3.10.0 |
This also doesn't fix the issue for me unfortunately.
|
switching to python 3.8 worked for me :) |
can confirm that on my side, running this command fixed the problem |
Issue wss already fixed earlier, no need for workarounds anymore.
El sáb, 27 may 2023, 17:44, P. Misirov ***@***.***> escribió:
… can confirm that on my side, running this command fixed the problem
pip install typing-inspect==0.8.0 typing_extensions==4.5.0
—
Reply to this email directly, view it on GitHub
<#5113 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACRLWUZGVKPH3N5VHV4W3DXIIOMNANCNFSM6AAAAAAYLG4KPY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Seconding this. I was still seeing errors despite the previously-posted solution. This command fixed it. |
python 3.10.6 |
That works for me, thanks |
As mentioned above, this has been fixed in Pydantic 1.10.8. No need to pin typing-inspect and typing_extensions if you are using Pydantic 1.10.8. For poetry, use |
Thanks !
|
fixed the issue with pydantic==1.10.8 |
|
Thankss! |
I am still getting this issue with Python 3.9.2 and pydantic==1.10.8 Should I be upgrading Python version (I am on Debian Release 11) |
System Info
all the dependencies
Who can help?
@hwchase17 @agola11
Information
Related Components
Reproduction
pip install langchain
with docker
Expected behavior
what to do?
change python dependency to 3.10 or laterThank you for checking out this issue. If there are anything more to check, I would be glad to help.
The text was updated successfully, but these errors were encountered: