ModuleNotFoundError: No module named 'langtrace_python_sdk'

This solved the issue for me:

The ModuleNotFoundError for langtrace_python_sdk in your CrewAI project indicates that the module isn’t accessible within the environment where CrewAI is running. To resolve this issue, follow these steps:

  1. Add langtrace_python_sdk as a Dependency in pyproject.toml:

    • Navigate to your CrewAI project’s directory.
    • Open the pyproject.toml file.
    • Under the [project] section, add langtrace_python_sdk to the dependencies list:
      [project]
      dependencies = [
        "crewai[tools]>=0.95.0,<1.0.0",
        "langtrace_python_sdk>=3.3"
      ]
      
    • Save the file.
  2. Reinstall Project Dependencies:

    • In the terminal, ensure you’re in your project’s root directory.
    • Run the following command to install the updated dependencies:
      crewai install
      
    • This command will set up a virtual environment specific to your project and install all listed dependencies, including langtrace_python_sdk.
  3. Verify the Installation:

    • After the installation completes, run your project:
      crewai run
      
    • If the ModuleNotFoundError persists, ensure that the langtrace_python_sdk is correctly installed in the virtual environment.
  4. Manual Installation (if necessary):

    • If issues continue, manually activate the virtual environment created by CrewAI:
      source .venv/bin/activate
      
    • Then, install the langtrace_python_sdk directly:
      pip install langtrace-python-sdk
      
    • After installation, deactivate the virtual environment:
      deactivate
      
    • Retry running your project with crewai run.

By ensuring that langtrace_python_sdk is listed as a dependency in your project’s pyproject.toml and properly installed within the project’s virtual environment, CrewAI should recognize and import the module without issues.

For more detailed information, refer to the Langtrace AI documentation on integrating with CrewAI: Langtrace AI Docs.

If you encounter further difficulties, consider consulting the CrewAI community forums for additional support.

2 Likes