AgentExecutor and ModuleNotFoundError/NameError
Labels: name: area: agent, name: auto:bug

### System Info

langchain == 292

### Who can help?

@hwchase17

### Information

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

### Related Components

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

### Reproduction

Here is my code:


```
agent_analytics_node = create_pandas_dataframe_agent(
                                                        llm, 
                                                        df, 
                                                        verbose=True, 
                                                        reduce_k_below_max_tokens=True, 
                                                        max_execution_time = 20,
                                                        early_stopping_method="generate", 
                                                    )

tool_analytics_node = Tool(
                                name='Analytics Node',
                                func=agent_analytics_node.run)

tools = [tool_analytics_node]


chat_agent = ConversationalChatAgent.from_llm_and_tools(llm=llm, tools=tools)


executor = AgentExecutor.from_agent_and_tools(
                                                        agent=chat_agent,
                                                        tools=tools,
                                                        memory=memory,
                                                        return_intermediate_steps=True,
                                                        handle_parsing_errors=True,
                                                        verbose=True,
                                                    )
with st.chat_message("assistant"):
 st_cb = StreamlitCallbackHandler(st.container(), expand_new_thoughts=False)
 response = executor(prompt, callbacks=[st_cb])

```

here output from the agent: ```

> Entering new AgentExecutor chain...
Thought: The question seems to be asking for the sentiment polarity of the 'survey_comment' column in the dataframe. The sentiment polarity is a measure that lies between -1 and 1. Negative values indicate negative sentiment and positive values indicate positive sentiment. The TextBlob library in Python can be used to calculate sentiment polarity. However, before applying the TextBlob function, we need to ensure that the TextBlob library is imported. Also, the 'dropna()' function is used to remove any NaN values in the 'survey_comment' column before applying the TextBlob function.
Action: python_repl_ast
Action Input: import TextBlob
Observation: ModuleNotFoundError: No module named 'TextBlob'
Thought:The TextBlob library is not imported. I need to import it from textblob module.
Action: python_repl_ast
Action Input: from textblob import TextBlob
Observation:
Thought:Now that the TextBlob library is imported, I can apply it to the 'survey_comment' column to calculate the sentiment polarity.
Action: python_repl_ast
Action Input: df['survey_comment'].dropna().apply(lambda x: TextBlob(x).sentiment.polarity)
Observation: NameError: name 'TextBlob' is not defined
```



### Expected behavior

agent should be able to install python packages.