KeyError: 'langchain' (circular import error)
Labels: name: stale

### System Info

@hwchase17
@agola11

Hi. From time to time, I am getting the following error:

```
2023-06-12 02:27:55.993 Uncaught app exception
Traceback (most recent call last):
File "C:\Users\v-alakubov\AppData\Local\anaconda3\envs\py311\Lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 565, in run_script
exec(code, module.dict)
File "C:\Users\v-alakubov\OneDrive\Desktop\app_v2\src\pages\AskData.py", line 7, in <module>
from modules.table_tool import PandasAgent
File "C:\Users\v-alakubov\OneDrive\Desktop\Listens\app_v2.\src\modules\table_tool.py", line 6, in <module>
from langchain.callbacks import get_openai_callback
File "C:\Users\v-alakubov\AppData\Local\anaconda3\envs\py311\Lib\site-packages\langchain_init.py", line 6, in <module>
from langchain.agents import MRKLChain, ReActChain, SelfAskWithSearchChain
File "C:\Users\v-alakubov\AppData\Local\anaconda3\envs\py311\Lib\site-packages\langchain\agents_init_.py", line 2, in <module>
from langchain.agents.agent import (
File "C:\Users\v-alakubov\AppData\Local\anaconda3\envs\py311\Lib\site-packages\langchain\agents\agent.py", line 16, in <module>
from langchain.agents.tools import InvalidTool
File "C:\Users\v-alakubov\AppData\Local\anaconda3\envs\py311\Lib\site-packages\langchain\agents\tools.py", line 8, in <module>
from langchain.tools.base import BaseTool, Tool, tool
File "C:\Users\v-alakubov\AppData\Local\anaconda3\envs\py311\Lib\site-packages\langchain\tools_init_.py", line 46, in <module>
from langchain.tools.powerbi.tool import (
File "C:\Users\v-alakubov\AppData\Local\anaconda3\envs\py311\Lib\site-packages\langchain\tools\powerbi\tool.py", line 11, in <module>
from langchain.chains.llm import LLMChain
File "C:\Users\v-alakubov\AppData\Local\anaconda3\envs\py311\Lib\site-packages\langchain\chains_init_.py", line 7, in <module>
from langchain.chains.conversational_retrieval.base import (
File "C:\Users\v-alakubov\AppData\Local\anaconda3\envs\py311\Lib\site-packages\langchain\chains\conversational_retrieval\base.py", line 22, in <module>
from langchain.chains.question_answering import load_qa_chain
File "C:\Users\v-alakubov\AppData\Local\anaconda3\envs\py311\Lib\site-packages\langchain\chains\question_answering_init_.py", line 13, in <module>
from langchain.chains.question_answering import (
File "C:\Users\v-alakubov\AppData\Local\anaconda3\envs\py311\Lib\site-packages\langchain\chains\question_answering\map_reduce_prompt.py", line 2, in <module>
from langchain.chains.prompt_selector import ConditionalPromptSelector, is_chat_model
File "C:\Users\v-alakubov\AppData\Local\anaconda3\envs\py311\Lib\site-packages\langchain\chains\prompt_selector.py", line 7, in <module>
from langchain.chat_models.base import BaseChatModel
ImportError: cannot import name 'BaseChatModel' from partially initialized module 'langchain.chat_models.base' (most likely due to a circular import) (C:\Users\v-alakubov\AppData\Local\anaconda3\envs\py311\Lib\site-packages\langchain\chat_models\base.py)
2023-06-12 02:27:56.013 Uncaught app exception
Traceback (most recent call last):
File "C:\Users\v-alakubov\AppData\Local\anaconda3\envs\py311\Lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 565, in _run_script
exec(code, module.dict)
File "C:\Users\v-alakubov\OneDrive\Desktop\Listens\app_v2\src\pages\AI-Chat.py", line 8, in <module>
from modules.utils import Utilities
File "C:\Users\v-alakubov\OneDrive\Desktop\Listens\app_v2.\src\modules\utils.py", line 6, in <module>
from modules.chatbot import Chatbot
File "C:\Users\v-alakubov\OneDrive\Desktop\Listens\app_v2.\src\modules\chatbot.py", line 3, in <module>
from langchain.chat_models import AzureChatOpenAI
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1155, in _find_and_load_unlocked
KeyError: 'langchain'
```

any ideas why? 

### 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
- [X] Callbacks/Tracing
- [ ] Async

### Reproduction

Here structure of project:

```
Home.py
pages
modules
embeddings
```

Where pages, modules and embeddings are folders. 


"pages" folder has two files:

AI-Chat.py
AskData.py

modules folder has 7 files:
chatbot.py
embedder.py
history.py
layout.py
sidebar.py
table_tool.py
utils.py



Home.py (the file I run as ` streamlit run .\src\Home.py`)


AI-Chat.py:

```
import os
import streamlit as st
from io import StringIO
import re
import sys
from modules.history import ChatHistory
from modules.layout import Layout
from modules.utils import Utilities
from modules.sidebar import Sidebar
....
```


AskData.py:
```
import os
import importlib
import sys
import pandas as pd
import streamlit as st
from io import BytesIO
from modules.table_tool import PandasAgent
from modules.layout import Layout
from modules.utils import Utilities
from modules.sidebar import Sidebar
....
```


chatbot.py:

```
import streamlit as st
# from langchain.chat_models import ChatOpenAI
from langchain.chat_models import AzureChatOpenAI
from langchain.chains import ConversationalRetrievalChain
from langchain.prompts.prompt import PromptTemplate
from langchain.callbacks import get_openai_callback
import os
#fix Error: module 'langchain' has no attribute 'verbose'
import langchain
langchain.verbose = False
import traceback
.....
```

utils.py:

```
import os
import pandas as pd
import streamlit as st
import pdfplumber
from modules.chatbot import Chatbot
from modules.embedder import Embedder
```


embedder.py:

```
import os
import pickle
import tempfile
from langchain.document_loaders.csv_loader import CSVLoader
from langchain.vectorstores import FAISS
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.document_loaders import PyPDFLoader
from langchain.document_loaders import TextLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
....
```

table_tool.py:

```
import re
import sys
from io import StringIO, BytesIO
import matplotlib.pyplot as plt
import streamlit as st
from langchain.callbacks import get_openai_callback
from streamlit_chat import message
import os
from pandasai import PandasAI
# from pandasai.llm.openai import OpenAI
from pandasai.llm.azure_openai import AzureOpenAI
....
```


history.py:

```
import os
import streamlit as st
from streamlit_chat import message
......

```


layout.py:

```
import streamlit as st
....
```

sidebar.py:

```
import streamlit as st
.......
```






### Expected behavior

no error should rise