Hello CrewAI Community,
I'm encountering a persistent `ImportError` when trying to set up a CrewAI project in a Google Colab environment, specifically related to importing `BaseTool` from the `crewai_tools` library. I've followed the standard installation steps and project structure (defining custom tools in separate files), but I'm consistently hitting this import issue.
**Problem Description:**
When running my main CrewAI script which imports custom tools defined in separate `.py` files within a `./tools` directory, I get the following error:
ImportError: cannot import name ‘BaseTool’ from ‘crewai_tools’ (/usr/local/lib/python3.12/dist-packages/crewai_tools/init.py)
In some instances, the error message has also been:
ModuleNotFoundError: No module named ‘crewai_tools.agents’
The traceback consistently points to the import statement for `BaseTool` within my tool definition files (e.g., `tools/research_tools.py`).
**Environment Details:**
* **Platform:** Google Colab
* **Python Version:** 3.12.11
* **Installed Library Versions:**
* `crewai-tools`: 0.73.1
* `crewai`: 0.193.2
* `langchain-google-genai`: 2.1.12
* (Other installed libraries as per the `!pip install` command)
**Project Structure (relevant parts):**
My project follows a structure where custom tools are defined in files within a `./tools` directory. For example, `tools/research_tools.py` contains:
```python
# Attempt 1 (causes ImportError: cannot import name 'BaseTool' from 'crewai_tools')
# from crewai_tools import BaseTool, SerperDevTool
# Attempt 2 (causes ModuleNotFoundError: No module named 'crewai_tools.agents')
from crewai_tools.agents import BaseTool
from crewai_tools import SerperDevTool
deep_research_tool = SerperDevTool()
(Note: I’ve tried both import paths based on troubleshooting.)
The main script imports these tools like this:
# ... other imports
from tools.research_tools import deep_research_tool
from tools.file_tools import file_write_tool, pdf_conversion_tool
from tools.presentation_tools import powerpoint_tool
# ... rest of the crew setup and kickoff
Steps Taken So Far:
-
Installed libraries using
!pip install crewai crewai_tools langchain_google_genai python-dotenv fpdf2 python-pptx. The output shows requirements are satisfied. -
Created
./toolsand./outputsdirectories using!mkdir -p. -
Created the tool files (
research_tools.py,file_tools.py,presentation_tools.py) in the./toolsdirectory by writing the code content to them. -
Attempted to import
BaseToolusing bothfrom crewai_tools import BaseToolandfrom crewai_tools.agents import BaseToolwithin the tool files. -
Restarted the Colab runtime multiple times and re-executed all cells sequentially in the correct order (install, mkdir, create tool files, set env vars, run main script).
-
Checked the installed
crewai-toolsversion (0.73.1). -
Reviewed the official CrewAI documentation and a Colab tutorial ( Google Colab ) which shows
from crewai_tools import BaseToolbeing used successfully.
Despite these steps, the import error for BaseTool persists when the main script tries to import the tool files.
Could this be a known issue with version 0.73.1 in Colab, or is there something specific about the Colab environment setup that I might be missing regarding importing from external files within a package structure?
Any guidance or suggestions from the community would be greatly appreciated!
Thank you.