unclecode/crawl4ai · error · ValueError

C4A script compiler not available. Please ensure crawl4ai.sc

Error message

C4A script compiler not available. Please ensure crawl4ai.script module is properly installed.

What it means

Raised when compiling js_source requires crawl4ai.script (the C4A compiler) and importing it fails. The core install does not include every optional dependency of the script compiler, so the feature degrades to this explicit error rather than a confusing ImportError.

Source

Thrown at crawl4ai/async_configs.py:1986

                if result.success:
                    compiled_js.extend(result.js_code)
                else:
                    # Format error message following existing patterns
                    error = result.first_error
                    error_msg = (
                        f"C4A Script compilation error (script {i+1}):\n"
                        f"  Line {error.line}, Column {error.column}: {error.message}\n"
                        f"  Code: {error.source_line}"
                    )
                    if error.suggestions:
                        error_msg += f"\n  Suggestion: {error.suggestions[0].message}"
                        
                    raise ValueError(error_msg)
                    
            self.js_code = compiled_js
            
        except ImportError:
            raise ValueError(
                "C4A script compiler not available. "
                "Please ensure crawl4ai.script module is properly installed."
            )
        except Exception as e:
            # Re-raise with context
            if "compilation error" not in str(e).lower():
                raise ValueError(f"Failed to compile C4A script: {str(e)}")
            raise
    
    def is_match(self, url: str) -> bool:
        """Check if this config matches the given URL.
        
        Args:
            url: The URL to check against this config's matcher
            
        Returns:
            bool: True if this config should be used for the URL or if no matcher is set.
        """

View on GitHub (pinned to 7e80152142)

Solutions

  1. Reinstall with the appropriate extras: pip install "crawl4ai[all]" (or the documented script/extra variant for your version)
  2. Verify the module imports: python -c "import crawl4ai.script"
  3. If you do not need C4A scripts, move the JS into plain js_code / js_source as standard JavaScript instead of DSL
  4. Repair a broken venv: pip install --force-reinstall crawl4ai

Example fix

// before
pip install crawl4ai
cfg = CrawlerRunConfig(js_source=my_c4a_script)
// after
pip install "crawl4ai[all]"
cfg = CrawlerRunConfig(js_source=my_c4a_script)
Defensive patterns

Strategy: fallback

Validate before calling

try:
    import crawl4ai.script  # noqa
    HAS_C4A = True
except ImportError:
    HAS_C4A = False

run_kwargs = {"js_source": scripts} if HAS_C4A else {"js_code": plain_js_equivalent}

Try / catch

try:
    cfg = CrawlerRunConfig(js_source=scripts)
except ValueError as e:
    if "compiler not available" in str(e):
        cfg = CrawlerRunConfig(js_code=plain_js)  # fallback to plain JS
    else:
        raise

Prevention

When it happens

Trigger: Installing crawl4ai without optional script-compiler dependencies (e.g. pip install crawl4ai instead of the full/extra variant), or a broken/partial install/venv where crawl4ai.script cannot import its third-party deps.

Common situations: Docker images trimmed for size; CI using minimal installs; upgrading crawl4ai where the script module's deps moved to an extra.

Related errors


AI-assisted analysis of unclecode/crawl4ai@7e80152142 (2026-08-14). Data as JSON: /api/errors/59459baa54ba5614. Report an issue: GitHub.