{"record":{"id":"1479067b7a351571","repo":"dbt-labs/dbt-core","slug":"an-unexpected-error-occurred-during-package-instal","errorCode":null,"errorMessage":"An unexpected error occurred during package installation: {e}","messagePattern":"An unexpected error occurred during package installation: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"crates/dbt-adapter/src/python/bigquery/mod.rs","lineNumber":653,"sourceCode":"\n    try:\n        result = subprocess.run(\n            pip_command,\n            capture_output=True,\n            text=True,\n            check=True,\n            encoding=\"utf-8\",\n        )\n        if result.stdout:\n            print(f\"pip output:\\n{result.stdout.strip()}\")\n        if result.stderr:\n            print(f\"pip warnings/errors:\\n{result.stderr.strip()}\")\n        print(\n            f\"Successfully installed the following packages: {', '.join(packages_to_install)}\"\n        )\n\n    except Exception as e:\n        raise RuntimeError(\n            f\"An unexpected error occurred during package installation: {e}\"\n        )\n\"#\n}\n","sourceCodeStart":635,"sourceCodeEnd":658,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-adapter/src/python/bigquery/mod.rs#L635-L658","documentation":"This RuntimeError wraps any failure from the embedded Python snippet that pip-installs user-requested packages (e.g. packages named in `dbt deps` / package config) during BigQuery adapter setup. It fires when `subprocess.run([sys.executable, '-m', 'pip', 'install', ...])` raises — most commonly CalledProcessError from a non-zero pip exit code, but also pip-not-found or environment errors. The original pip exception `e` is interpolated into the message so the root cause is visible.","triggerScenarios":"The Python helper function source generated by get_install_packages_function_source is executed and `pip install <packages>` exits non-zero (CalledProcessError), pip is missing/broken, or any other exception occurs inside the install block — reached via convert_py_to_ipynb.","commonSituations":"A required package name/version spec doesn't exist on PyPI or is incompatible with the Python version; no network access or a private index is needed; pip itself is broken or points at a different interpreter; disk space exhaustion during install.","solutions":["Read the wrapped `{e}` message and re-run the failing `pip install` command manually to see full pip output","Fix the package spec (name typo, version pin, or Python-version compatibility) in the package config","Check network/proxy access and any configured index (pip config, PIP_INDEX_URL)","Verify `python -m pip` works in the environment; repair or upgrade pip if broken","If the package is already installed with an incompatible version, uninstall or upgrade it manually"],"exampleFix":"// before (user package config)\npackages: [\"google-cloud-bigquery==99.0.0\"]\n// after\npackages: [\"google-cloud-bigquery>=3.0,<4.0\"]  // version that exists and supports your Python","handlingStrategy":"try-catch","validationCode":"import importlib.metadata, packaging.requirements\nreq = packaging.requirements.Requirement(\"google-cloud-bigquery>=3.0\")\ntry:\n    importlib.metadata.version(req.name)\n    installed = True\nexcept importlib.metadata.PackageNotFoundError:\n    installed = False\n# also verify pip works first: subprocess.run([sys.executable, '-m', 'pip', '--version'], check=True)","typeGuard":"def is_pip_ok() -> bool:\n    import subprocess, sys\n    return subprocess.run([sys.executable, \"-m\", \"pip\", \"--version\"], capture_output=True).returncode == 0","tryCatchPattern":"try:\n    install_packages(packages)\nexcept RuntimeError as e:\n    logger.error(\"package install failed: %s\", e)  # inspect wrapped pip error\n    raise SystemExit(1)","preventionTips":["Pin package versions that exist and support your Python version","Verify network/index access before running installs in CI","Check installed packages/satisfying versions before install (the code already skips satisfied requirements)","Keep pip upgraded in the target environment"],"tags":["pip","package-installation","python","bigquery"],"backgroundTag":"upstream-api-error","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}