huggingface/open-r1 · error
MorphCloud is not available and required for this function.
Error message
MorphCloud is not available and required for this function. Please install MorphCloud with `pip install morphcloud` and add an API key to a `.env` file.
What it means
get_morph_client_from_env requires the MorphCloud SDK plus a configured API key. is_morph_available() checks importability (and configuration); if it fails, the factory raises ImportError telling the user to install morphcloud and provide an API key via a .env file.
Source
Thrown at src/open_r1/utils/competitive_programming/morph_client.py:729
esac
"""
def get_morph_client_from_env(session=None) -> MorphCloudExecutionClient:
"""
Creates a MorphCloudExecutionClient instance using environment variables.
Environment variables:
MORPH_API_KEY: API key for MorphCloud
Args:
session: Optional aiohttp.ClientSession to use for HTTP requests
Returns:
MorphCloudExecutionClient: A configured MorphCloud execution client
"""
if not is_morph_available():
raise ImportError(
"MorphCloud is not available and required for this function. Please install MorphCloud with "
"`pip install morphcloud` and add an API key to a `.env` file."
)
load_dotenv()
api_key = os.environ.get("MORPH_API_KEY")
if not api_key:
raise ValueError("MORPH_API_KEY environment variable is required")
return MorphCloudExecutionClient(api_key=api_key)
# noqa: W293
View on GitHub (pinned to 1416fa0cf2)
Solutions
- Install the SDK: pip install morphcloud.
- Complete MorphCloud setup (morphcloud auth / config) so is_morph_available() passes.
- Add MORPH_API_KEY=... to your .env file in the working directory.
- Alternatively use the Piston backend by setting PISTON_ENDPOINTS instead of the Morph backend.
Example fix
// before pip install vllm # morphcloud missing // after pip install morphcloud && echo 'MORPH_API_KEY=your-key' >> .env
Defensive patterns
Strategy: fallback
Validate before calling
import importlib.util
if importlib.util.find_spec('morphcloud') is None:
raise SystemExit('morphcloud not installed: pip install morphcloud') Type guard
def is_morph_ready() -> bool:
try:
import morphcloud # noqa: F401
return True
except ImportError:
return False Try / catch
try:
client = get_morph_client_from_env()
except ImportError:
logger.warning('MorphCloud unavailable; falling back to Piston backend')
client = get_piston_client_from_env() Prevention
- Pin morphcloud in requirements and install in all environments (CI, workers)
- Run a bootstrap check that verifies imports and .env keys at job start
- Document the morph backend prerequisites in your runbook
When it happens
Trigger: Calling ioi_code_reward (with morph backend) on a machine where the morphcloud package isn't installed or is incompletely configured, so is_morph_available() returns False before the API key is even read.
Common situations: Running the reward pipeline in a fresh container/venv without pip install morphcloud; MorphCloud installed but its config/credentials setup not completed so the availability check fails; switching workers without replicating the environment.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- E2B is not available and required for this provider. Please
- MorphCloud is not available and required for this provider.
- Could not determine problem ID from files
- Compilation error exit code {compile_result.exit_code} {comp
- MORPH_API_KEY environment variable is required
AI-assisted analysis of huggingface/open-r1@1416fa0cf2 (2026-08-30).
Data as JSON: /api/errors/fdab134e7372a677.
Report an issue: GitHub.