Andy
Andy

Reputation: 441

python import error in Microsoft fabric notebook

I was trying to import some langchain modules in a notebook in Microsoft Fabric like below.

The notebook is using Python 3.10

Step 1: pip install langchain openai --> successful

Step 2:

from langchain.llms import OpenAI
from langchain.llms import AzureOpenAI
from langchain import PromptTemplate
from langchain.chat_models import ChatOpenAI
from langchain.chains import LLMChain

getting the below error:

ImportError: cannot import name 'TypeAliasType' from 'typing_extensions' (/home/trusted-service-user/cluster-env/trident_env/lib/python3.10/site-packages/typing_extensions.py)

I tried updating the typing_extensions module in Python but nothing seems to work.

Can some please help.

Upvotes: 1

Views: 976

Answers (1)

Rakesh Govindula
Rakesh Govindula

Reputation: 11329

I tried the same scenario in my environment, and I got same error while importing.

enter image description here

I followed the suggestion by @anovoselov from this ask and now it is working fine for me.

Try to re-import the typing_extensions from the sys.path before importing the langchain.

import sys
del sys.modules["typing_extensions"]

enter image description here

Upvotes: 1

Related Questions