Skip to content
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

No module named "_gdbm" #339

Open
prasiyer opened this issue Jan 23, 2025 · 2 comments
Open

No module named "_gdbm" #339

prasiyer opened this issue Jan 23, 2025 · 2 comments

Comments

@prasiyer
Copy link

prasiyer commented Jan 23, 2025

Code:
qwen_model = HfApiModel("Qwen/Qwen2.5-Coder-32B-Instruct", token = hf_token)
data_analyst_agent_qwen = CodeAgent(
tools=[],
model=qwen_model,
additional_authorized_imports=["numpy", "pandas", "matplotlib.pyplot", "seaborn"],
max_steps=10,
)
data_analyst_agent_qwen.run(data_analyst_prompt, additional_args = dict(source_file_path = input_file_path))

Result:
Error when smolagent is executing the following code during one of the steps. This code is generated by the llm during step 1. The following code runs without any error when I run it in a separate notebook. Logs are not showing any additional information. Error message: No module named "_gdbm". The error seems to be generated by the code for the plots. Agent works without any issues if I "EXCLUDE" the requirement about generating charts.

import matplotlib.pyplot as plt
import seaborn as sns

plt.figure(figsize=(15, 10))

plt.subplot(2, 2, 1)
sns.boxplot(x='Product_3', y='Stroke_Length', data=df)
plt.title('Distribution of Stroke_Length by Product_3')
plt.xticks(rotation=45)

plt.subplot(2, 2, 2)
sns.boxplot(x='Cylinder_Function', y='Closed_Length_mm', data=df)
plt.title('Distribution of Closed_Length_mm by Cylinder_Function')
plt.xticks(rotation=90)

plt.subplot(2, 2, 3)
sns.boxplot(x='Type_2', y='Attributes_Rod_ID', data=df)
plt.title('Distribution of Attributes_Rod_ID by Type_2')

plt.subplot(2, 2, 4)
sns.boxplot(x='Type_2', y='Attributes_Internal_Bore', data=df)
plt.title('Distribution of Attributes_Internal_Bore by Type_2')

plt.tight_layout()
plt.show()

question1 = "What is the average Stroke_Length for each Product_3 category?"
question2 = "What is the maximum Closed_Length_mm for each Cylinder_Function category?"
question3 = "What is the average Attributes_Rod_ID for each Type_2 category?"

answer1 = df.groupby('Product_3')['Stroke_Length'].mean()
answer2 = df.groupby('Cylinder_Function')['Closed_Length_mm'].max()
answer3 = df.groupby('Type_2')['Attributes_Rod_ID'].mean()

print("Question 1:", question1)
print("Answer 1:", answer1)
print("\nQuestion 2:", question2)
print("Answer 2:", answer2)
print("\nQuestion 3:", question3)
print("Answer 3:", answer3)

@albertvillanova
Copy link
Member

I think this issue is not related to the smolagents library, but to your local Python environment.

@prasiyer
Copy link
Author

@albertvillanova
I am not certain that the problem is with the local python environment. If I copy the code generated by the llm and run it in a notebook within my local environment, the code works just fine. However, when the agent is trying to run it within the python-interpretor, it encounters the "Missing _gdbm module" error. Can you pls provide some suggestions to debug this further?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants