langchain icon indicating copy to clipboard operation
langchain copied to clipboard

Can not import NotRequired from typing_extensions.py

Open AniketModi opened this issue 2 years ago • 1 comments

System Info

Langchain version >= 0.0.198 and python version 3.9

Who can help?

No response

Information

  • [ ] The official example notebooks/scripts
  • [ ] My own modified scripts

Related Components

  • [x] LLMs/Chat Models
  • [ ] Embedding Models
  • [ ] Prompts / Prompt Templates / Prompt Selectors
  • [ ] Output Parsers
  • [ ] Document Loaders
  • [ ] Vector Stores / Retrievers
  • [ ] Memory
  • [ ] Agents / Agent Executors
  • [ ] Tools / Toolkits
  • [ ] Chains
  • [ ] Callbacks/Tracing
  • [ ] Async

Reproduction

  1. install python3.9

  2. install following requirements Flask==1.0.2 jsonobject== 2.1.0 gunicorn==20.1.0 gevent==21.12.0 greenlet==1.1.2 py-healthcheck==1.9.0 aenum==2.2.3 flask-log-request-id==0.10.1 numpy==1.19.5 faiss-cpu==1.7.0 sentence-transformers==2.2.2 contractions==0.0.25 grpcio==1.39.0 tensorflow==2.6.0 tensorflow-serving-api==2.5.2 keras==2.6.0 PyYAML~=6.0 setuptools~=60.10.0 requests~=2.28.2 Werkzeug~=2.2.3 transformers~=4.21.3 Jinja2>=2.10.1,<3.1 itsdangerous==2.0.1 elastic-apm[flask]==6.7.0 langchain==0.0.198 openai==0.27.4 redis==4.5.4 tiktoken==0.2.0 mysql-connector-python==8.0.33 kafka-python==2.0.2 pymongo==3.6.1

  3. import following library -- from langchain.chains.conversational_retrieval.prompts import CONDENSE_QUESTION_PROMPT, QA_PROMPT

Expected behavior

When I am running project with LangChain >= 0.0.198, I am getting exception that Can't Import NotRequired from typing_extensions.py.

AniketModi avatar Jun 15 '23 18:06 AniketModi

Generated by a 🤖

Answer

I found related issues that might be helpful. I did my best to summarize the solutions, but I recommend looking at the related issues yourself.

Related Issues

Closed Issues

import langchain with python<=3.9 fails

The suggested solution is: Update pydantic to the latest version (1.10.8) which has fixed the issue as mentioned in this pull request. LangChain does not need an update as its pydantic dependency is already set to > 1.

To update pydantic, you can run:

pip install --upgrade pydantic

Then, you can test the update with the following commands:

python -m "import langchain"
pip freeze | grep pydantic

This response is meant to be helpful and save users time. It is not meant to be a precise solution.

Please leave a 👍 if this is helpful and 👎 if it is irrelevant

devstein avatar Jun 16 '23 17:06 devstein

Hi, @AniketModi! I'm Dosu, and I'm helping the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.

Based on my understanding, you reported an issue where running a project with LangChain version 0.0.198 or higher throws an exception related to importing "NotRequired" from typing_extensions.py. devstein suggested updating pydantic to the latest version (1.10.8) as it has fixed similar issues in the past. They provided instructions on how to update pydantic and test the update.

Before we close this issue, we wanted to check with you if it is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on this issue. Otherwise, feel free to close the issue yourself or it will be automatically closed in 7 days.

Thank you for your contribution to the LangChain repository!

dosubot[bot] avatar Sep 15 '23 16:09 dosubot[bot]