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

getting ModuleNotFoundError: No module named 'matplotlib' #152

Open
barissecen opened this issue Dec 18, 2024 · 1 comment
Open

getting ModuleNotFoundError: No module named 'matplotlib' #152

barissecen opened this issue Dec 18, 2024 · 1 comment

Comments

@barissecen
Copy link

barissecen commented Dec 18, 2024

Hi there,

Kindly need your help. In my crew, I am using allow_code_execution tool to generate my images by one of my agent to write a python code and run it but somehow in my docker environment not able to install matplotlib which is necessary to visiualize my data and then generate images. Thanks.

Error message: ## Tool Output: Something went wrong while running the code: Traceback (most recent call last): File "", line 2, in ModuleNotFoundError: No module named 'matplotlib'

Some extra infos:
Mac, my python version in .venv: 3.11.5

@reproduce-bot
Copy link

The following script is generated by AI Agent to help reproduce the issue:

# crewAI-tools/reproduce.py
import unittest
import sys
import os
os.environ['OPENAI_API_KEY'] = 'mock_openai_api_key'

from unittest.mock import MagicMock

sys.modules['weaviate'] = MagicMock()
sys.modules['weaviate.classes'] = MagicMock()
sys.modules['weaviate.classes.config'] = MagicMock()
sys.modules['weaviate.classes.init'] = MagicMock()

from crewai_tools.tools.code_interpreter_tool.code_interpreter_tool import CodeInterpreterTool

class TestMatplotlibImport(unittest.TestCase):
    def test_matplotlib_import(self):
        tool = CodeInterpreterTool()
        code = "import matplotlib.pyplot as plt; plt.plot([1, 2, 3], [4, 5, 6]); plt.show()"
        libraries_used = ["matplotlib"]
        
        try:
            result = tool.run_code_in_docker(code, libraries_used)
            print("Test passed successfully with no errors!")
        except Exception as e:
            raise AssertionError("Test failed as expected with error: " + str(e))

if __name__ == "__main__":
    unittest.main()

How to run:

python3 crewAI-tools/reproduce.py

Thank you for your valuable contribution to this project and we appreciate your feedback! Please respond with an emoji if you find this script helpful. Feel free to comment below if any improvements are needed.

Best regards from an AI Agent!

@barissecen

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