#!/usr/bin/env bash set -euo pipefail ENV_NAME="${1:-crewai_test}" ENV_DIR="/Applications/anaconda3/envs/$ENV_NAME" ENV_PYTHON="$ENV_DIR/bin/python" ENV_PIP="$ENV_PYTHON -m pip" echo ">>> Creating conda env: $ENV_NAME" conda create -n "$ENV_NAME" python=3.12 -y # ------------------------------------------------------------------ # DEPENDENCY RESOLUTION STRATEGY # # pip's resolver refuses to install packages with conflicting # declared metadata, even when they work fine at runtime. The known # conflicts are: # # crewai 1.9.3 → openai~=1.83, aiosqlite~=0.21, opentelemetry-sdk~=1.34, pydantic~=2.11, tokenizers~=0.20 # litellm 1.88.1 → openai>=2.20, tokenizers>=0.21 # arize-phoenix 17.2.0 → aiosqlite>=0.22, opentelemetry-sdk (any), pydantic-ai-slim (any) # # At runtime all version pairs are compatible. The workaround is to # install in layers with --no-deps for the conflicting packages. # # Step 1 — Install base deps (pip resolves these cleanly). # Step 2 — Override openai + litellm (--no-deps bypasses the ~=1.83/>=2.20 clash). # Step 3 — Override OTel to 1.42.x (phoenix needs semconv attrs missing from 0.55). # Step 4 — Install phoenix's heavy transitive deps (scikit-learn, pydantic-ai-slim, …). # Step 5 — Install arize-phoenix itself (--no-deps bypasses aiosqlite/OTel clash). # ------------------------------------------------------------------ echo ">>> Step 1 — base packages" $ENV_PIP install \ crewai==1.9.3 crewai-tools==1.9.3 \ python-dotenv==1.1.1 httpx==0.28.1 modal==1.5.0 gradio==6.17.3 \ openinference-instrumentation-crewai==1.1.9 \ openinference-instrumentation-openai==0.1.51 \ --only-binary :all: echo ">>> Step 2 — upgrade openai + install litellm (--no-deps)" $ENV_PIP install "openai>=2.20.0,<3.0.0" litellm==1.88.1 fastuuid --no-deps --force-reinstall echo ">>> Step 3 — upgrade OTel packages for phoenix compat (--no-deps)" $ENV_PIP install \ "opentelemetry-sdk>=1.42.0" \ "opentelemetry-semantic-conventions>=0.60b0" \ "opentelemetry-api>=1.42.0" \ "opentelemetry-exporter-otlp>=1.42.0" \ "opentelemetry-proto>=1.42.0" \ --no-deps --force-reinstall echo ">>> Step 4 — phoenix transitive deps" $ENV_PIP install \ aioitertools alembic email-validator authlib joserfc jsonpath-ng ldap3 \ grpc-interceptor prometheus-client psutil pystache sqlean-py strawberry-graphql \ jmespath "aiosqlite>=0.22.1" \ "pydantic-ai-slim>=1.95.0" anthropic "google-genai>=1.0.0" \ "mcp>=1.27.0" "tokenizers>=0.21.0" \ --only-binary :all: echo ">>> Step 5 — scikit-learn metadata (phoenix reads its version at import)" $ENV_PIP install scikit-learn --force-reinstall --only-binary :all: echo ">>> Step 6 — arize-phoenix itself (--no-deps)" $ENV_PIP install arize-phoenix==17.2.0 arize-phoenix-client arize-phoenix-evals arize-phoenix-otel --no-deps echo ">>> Verifying import..." $ENV_PYTHON -c " from phoenix.otel import register from openinference.instrumentation.openai import OpenAIInstrumentor from crew2 import run_pipeline, generate_image, generate_voice, transcribe_audio print('All imports OK') " 2>&1 | grep -E '^All|Traceback|Error' echo "" echo "=== Setup complete: $ENV_NAME ===" echo "Run: conda activate $ENV_NAME && python app.py"