huggingface/open-r1 · error
Required MorphCloud dependencies not installed: {e}
Error message
Required MorphCloud dependencies not installed: {e} What it means
This ImportError wraps an ImportError raised while constructing MorphCloudClient or binding the Sandbox class inside MorphProvider.__init__. The original exception message is interpolated into `{e}`, so it means morphcloud's own internal dependencies (or a partial install) are broken even though the top-level import passed the earlier availability check.
Source
Thrown at src/open_r1/utils/code_providers.py:209
self.num_parallel = num_parallel
self.morph_router_url = morph_router_url
if self.morph_router_url is not None:
self.routed_sandbox = RoutedMorphSandbox(router_url=self.morph_router_url)
return
import os
self.api_key = os.getenv("MORPH_API_KEY")
if not self.api_key:
raise ValueError("MorphCloud API key not found. Please set the MORPH_API_KEY environment variable.")
try:
self.client = MorphCloudClient(api_key=self.api_key)
self.Sandbox = Sandbox
except ImportError as e:
raise ImportError(f"Required MorphCloud dependencies not installed: {e}")
def execute_scripts(self, scripts: List[str], languages: List[str]) -> List[float]:
"""Execute scripts using MorphCloud Sandbox API.
Args:
scripts: List of Python scripts to execute
language: Programming language
Returns:
List of float rewards (one per script)
"""
if hasattr(self, "routed_sandbox"):
try:
results = self.routed_sandbox.run_code(
scripts=scripts,
languages=languages,
timeout=90,View on GitHub (pinned to 1416fa0cf2)
Solutions
- Read the wrapped message in {e} to identify the actual missing module
- Reinstall cleanly: pip install --force-reinstall -U morphcloud
- Install any extras morphcloud documents (e.g. pip install 'morphcloud[all]')
- Pin/align conflicting dependency versions named in the inner error
Example fix
// before provider = MorphProvider() # ImportError: Required MorphCloud dependencies not installed: No module named 'morphcloud.sandbox' // after # shell: pip install --force-reinstall -U morphcloud provider = MorphProvider() # works
Defensive patterns
Strategy: try-catch
Validate before calling
def check_morph_client():
try:
from morphcloud.api import MorphCloudClient # noqa: F401
except ImportError as e:
raise SystemExit(f"morphcloud broken install: {e}; run pip install --force-reinstall -U morphcloud") from e Type guard
def morph_client_importable() -> bool:
try:
from morphcloud.api import MorphCloudClient # noqa: F401
return True
except ImportError:
return False Try / catch
try:
provider = MorphProvider()
except ImportError as e:
logger.error("MorphCloud deps broken: %s", e)
logger.error("Fix with: pip install --force-reinstall -U morphcloud")
raise SystemExit(1) from e Prevention
- Pin morphcloud and its key transitive deps in a lockfile
- Use a clean venv per project to avoid version conflicts
- Re-run pip check in CI to catch broken dependency graphs
- Read the inner {e} message first — it names the actual missing module
When it happens
Trigger: MorphProvider.__init__ executes `self.client = MorphCloudClient(api_key=...)` or `self.Sandbox = Sandbox` and one of those imports raises ImportError — e.g. morphcloud installed with missing extras, a broken transitive dependency, or a version whose submodule layout changed.
Common situations: Pip resolved an old/incompatible morphcloud version; a partial install after a network failure; conflicting package versions (e.g. pydantic/httpx pinned elsewhere) breaking morphcloud's imports; importing Sandbox from a submodule path that moved between versions.
Related errors
- E2B is not available and required for this provider. Please
- MorphCloud is not available and required for this provider.
- Either `dataset_name` or `dataset_mixture` must be provided
- dataset_mixture must be a dictionary with a 'datasets' key.
- 'datasets' must be a list of dataset configurations
AI-assisted analysis of huggingface/open-r1@1416fa0cf2 (2026-08-30).
Data as JSON: /api/errors/e9a0c85db789e742.
Report an issue: GitHub.