{"id":967,"library":"wandb","title":"Weights & Biases (wandb)","description":"Weights & Biases (wandb) is a MLOps platform for experiment tracking, model optimization, and collaboration, widely used by machine learning practitioners. It provides a CLI and Python library to log metrics, visualize results, and manage models from experimentation to production. The library is actively maintained with frequent releases, typically on a monthly or bi-monthly cadence, and is currently at version 0.25.1.","status":"active","version":"0.25.1","language":"python","source_language":"en","source_url":"https://github.com/wandb/wandb","tags":["machine learning","experiment tracking","deep learning","visualization","MLOps","model management","hyperparameter tuning","artifacts"],"install":[{"cmd":"pip install wandb","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Requires Python 3.9 or higher. Python 3.8 support was dropped in version 0.25.0.","package":"python","optional":false}],"imports":[{"symbol":"wandb","correct":"import wandb"},{"symbol":"wandb.init","correct":"import wandb\nwandb.init(...)"},{"symbol":"wandb.login","correct":"import wandb\nwandb.login()"}],"quickstart":{"code":"import wandb\nimport os\n\n# Authenticate with W&B. For automated environments, use an environment variable.\n# wandb.login() will prompt for an API key if not set.\n# Set WANDB_API_KEY environment variable for CI/CD or headless environments.\n# For local development, running `wandb login` in your terminal is common.\n# os.environ.get('WANDB_API_KEY', '') # Example for fetching from env, but wandb.login() handles this.\nwandb.login()\n\n# Initialize a new W&B run\nproject_name = os.environ.get('WANDB_PROJECT', 'my-awesome-project')\nconfig = {\n    'epochs': 10,\n    'lr': 0.01,\n    'batch_size': 32\n}\n\nwith wandb.init(project=project_name, config=config) as run:\n    # Access hyperparameters\n    epochs = run.config.epochs\n    learning_rate = run.config.lr\n\n    print(f\"Starting training for {epochs} epochs with LR: {learning_rate}\")\n\n    # Simulate a training loop\n    for epoch in range(epochs):\n        # Simulate loss and accuracy metrics\n        loss = 1.0 / (epoch + 1) + 0.1 * (epochs - epoch - 1) / epochs\n        accuracy = 0.5 + 0.5 * (epoch + 1) / epochs\n\n        # Log metrics to W&B\n        run.log({\"epoch\": epoch, \"loss\": loss, \"accuracy\": accuracy})\n        print(f\"Epoch {epoch+1}/{epochs}: Loss = {loss:.4f}, Accuracy = {accuracy:.4f}\")\n\n    print(\"Training complete!\")","lang":"python","description":"This quickstart demonstrates how to initialize a Weights & Biases run, log hyperparameters using `wandb.config`, and track metrics like loss and accuracy using `run.log()` within a simulated training loop. Before running, ensure you have authenticated with `wandb.login()` or set the `WANDB_API_KEY` environment variable."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher.","message":"Python 3.8 is no longer supported starting from `wandb` version 0.25.0.","severity":"breaking","affected_versions":">=0.25.0"},{"fix":"Migrate to the modern artifact API using `Run.log_artifact()`, `Run.use_artifact()`, and `Run.link_artifact()` methods.","message":"The legacy `wandb.beta.workflows` module (including `log_model()`, `use_model()`, `link_model()`) was removed in version 0.24.0. These functions are no longer available and will cause `AttributeError`.","severity":"breaking","affected_versions":">=0.24.0"},{"fix":"Immediately upgrade to `wandb` version `0.24.1` or higher. Missing data from `0.24.0` runs can often be recovered by running `wandb sync` on the `.wandb` files.","message":"Version `0.24.0` was yanked from PyPI due to a critical bug that could cause silent failure to upload some run data. If used, data might be missing from your W&B dashboard.","severity":"breaking","affected_versions":"0.24.0"},{"fix":"Use the direct properties instead: `run.project`, `run.url`, `run.project_url`, and `run.sweep_url` respectively.","message":"Several `wandb.Run` methods are deprecated in favor of direct properties, including `run.project_name()`, `run.get_url()`, `run.get_project_url()`, and `run.get_sweep_url()`.","severity":"deprecated","affected_versions":"Likely from ~0.22.x onwards, to be removed in future versions (already deprecated since #8925)."},{"fix":"Check script for exceptions, monitor system resources (CPU/RAM), verify stable network connection, and ensure data logged to `wandb.log()` is in the correct dictionary format.","message":"The `wandb: ERROR Run aborted` or `wandb: ERROR Failed to log data` messages indicate an unexpected termination or data logging failure. This can be caused by script errors, system resource constraints, or network connectivity issues.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure reproducibility of splits (e.g., set `random_state` or explicitly manage dataset versions as W&B Artifacts) to maintain consistent evaluation benchmarks across experiments.","message":"Programmatic dataset splitting (e.g., using `sklearn.model_selection.train_test_split` without fixing `random_state` or without managing splits as artifacts) can lead to inconsistent train/test sets when new data is added, invalidating comparisons between experiments.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure you have logged in using `wandb login` in your terminal or script, or by setting the `WANDB_API_KEY` environment variable with your API key (available from your W&B settings page).","message":"The `wandb.errors.errors.UsageError: No API key configured` indicates that the W&B API key has not been set up, preventing authentication. This is a common first-time setup error when calling `wandb.login()` or any method that requires authentication.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure you have logged in via the command line (`wandb login`), set the `WANDB_API_KEY` environment variable, or passed the API key directly to `wandb.login(key='YOUR_API_KEY')`.","message":"The `wandb.login()` function raises `wandb.errors.errors.UsageError: No API key configured` if it cannot find an API key, preventing any W&B operations.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'0.25.1':65 'activ':46 'artifact':78 'bi':57 'bi-month':56 'bias':2,5 'cadenc':59 'cli':27 'collabor':17 'current':62 'deep':70 'experi':12,68 'experiment':40 'frequent':49 'hyperparamet':76 'learn':22,67,71 'librari':30,44 'log':32 'machin':21,66 'maintain':47 'manag':37,75 'metric':33 'mlop':9,73 'model':14,38,74 'month':54,58 'optim':15 'platform':10 'practition':23 'product':42 'provid':25 'python':29 'releas':50 'result':35 'track':13,69 'tune':77 'typic':51 'use':19 'version':64 'visual':34,72 'wandb':3,6 'weight':1,4 'wide':18","created_at":"2026-03-29T06:09:53.255541+00:00","updated_at":"2026-04-17T00:24:10.054809+00:00","problems":[{"fix":"pip install wandb","cause":"The `wandb` library is not installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'wandb'"},{"fix":"Run `wandb login` in your terminal and follow the prompts, or set the WANDB_API_KEY environment variable.","cause":"The Weights & Biases API key is not configured, which is required to authenticate and log runs to the W&B server.","error":"wandb: ERROR W&B API key is not set. Please set the WANDB_API_KEY environment variable or run `wandb login`"},{"fix":"Ensure `wandb.init()` is called only once per experiment run, or explicitly call `wandb.finish()` before subsequent `wandb.init()` calls.","cause":"`wandb.init()` was called multiple times within the same process without properly finishing the previous run.","error":"ValueError: This experiment has already been initialized."},{"fix":"Convert the `int64` value to a standard Python integer (`int`) before logging, e.g., `int(numpy_int64_value)`.","cause":"Attempting to log a NumPy `int64` type directly with `wandb.log()`, which is not natively JSON serializable.","error":"TypeError: Object of type int64 is not JSON serializable"},{"fix":"Ensure `wandb.finish()` is called only once at the end of an active `wandb.init()` run, or guard it with `if wandb.run: wandb.finish()`.","cause":"`wandb.finish()` was called when no active Weights & Biases run was initialized or if the run had already finished.","error":"wandb: WARNING wandb.finish() was called but there is no active run."}],"ecosystem":"pypi","meta_description":null,"install_score":95,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.29.0","cli_name":"wandb","cli_version":"wandb, version 0.27.0","type":"library","homepage":"https://wandb.ai","github":"https://github.com/wandb/wandb","docs":"https://docs.wandb.ai","changelog":null,"pypi":"https://pypi.org/project/wandb/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml","llm-agents","observability","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-27","next_check":"2026-07-28","install_tag":"verified"}}