{"id":9073,"library":"lerobot","title":"LeRobot","description":"LeRobot is a state-of-the-art open-source Python library for real-world robotics using PyTorch, developed by Hugging Face. It provides tools for creating robot environments, loading pre-trained policies, and managing robotics datasets. It is currently at version 0.5.1 and is under active development, with new releases often including significant updates and breaking changes.","status":"active","version":"0.5.1","language":"en","source_language":"en","source_url":"https://github.com/lerobot/lerobot","tags":["robotics","pytorch","machine-learning","reinforcement-learning","huggingface","mlops"],"install":[{"cmd":"pip install lerobot","lang":"bash","label":"Install core library"},{"cmd":"pip install 'lerobot[all]'","lang":"bash","label":"Install with all optional dependencies (e.g. for mujoco)"}],"dependencies":[],"imports":[{"note":"The policy loading utility was moved to a submodule under `hf_hub`.","wrong":"from lerobot.common.policies.load import load_policy","symbol":"load_policy","correct":"from lerobot.common.policies.hf_hub.load import load_policy"},{"symbol":"RobotEnvFactory","correct":"from lerobot.common.robot_env_factory import RobotEnvFactory"},{"symbol":"PolicyFactory","correct":"from lerobot.common.policies.factory import PolicyFactory"},{"symbol":"DatasetFactory","correct":"from lerobot.common.datasets.factory import DatasetFactory"}],"quickstart":{"code":"from lerobot.common.policies.hf_hub.load import load_policy\nfrom lerobot.common.robot_env_factory import RobotEnvFactory\nimport torch\n\n# Load a pre-trained policy from the Hugging Face Hub\n# This example uses a public model, so no explicit token is needed unless fine-tuning.\npolicy = load_policy(\"lerobot/diffusion_policy_v2_pen_push_multi_view_taco_play_sok_fixed_camera_v0\")\n\n# Create a dummy robot environment for demonstration\n# Real environments require specific configurations like 'robomimic', 'taco_play', etc.\n# e.g., env = RobotEnvFactory(\"taco_play\", record_dir=\"./recordings\")()\nenv = RobotEnvFactory(\"dummy\")()\n\n# Reset the environment to get initial observation\nobs = env.reset()\n\n# Sample actions from the policy\nwith torch.no_grad():\n    action = policy.sample_actions(obs)\n\nprint(f\"Initial observation keys: {obs.keys()}\")\nprint(f\"Sampled action shape: {action.shape}\")\nenv.close()","lang":"python","description":"This quickstart demonstrates how to load a pre-trained robotics policy from the Hugging Face Hub and use it to sample actions in a dummy environment. It showcases the core `load_policy` and `RobotEnvFactory` components."},"warnings":[{"fix":"Ensure `DatasetFactory` is called with `DatasetFactory(root_dir='/path/to/data')`. For instance, `DatasetFactory(\"hf_dataset_id\", root_dir=\"./data\")`.","message":"The `DatasetFactory` now requires the `root_dir` argument to be explicitly provided during instantiation. It was previously optional.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Replace `hf_hub_id='your/model'` with `repo_id='your/model'` when loading policies or datasets from the Hugging Face Hub.","message":"The `hf_hub_id` argument in functions like `load_policy` has been renamed to `repo_id` for consistency with Hugging Face Hub terminology.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Update calls from `action = policy.sample()` to `action = policy.sample_actions(obs)`.","message":"The signature and name of the policy sampling method have changed. `policy.sample()` is now `policy.sample_actions(obs)` and requires the current observation as input.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Ensure your Python environment is `3.12` or newer, and PyTorch is `2.1` or newer. Use `pip install torch` to update PyTorch if needed.","message":"LeRobot requires Python 3.12+ and PyTorch >= 2.1. Incompatibilities can lead to installation issues or runtime errors.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Pass a `root_dir` argument: `DatasetFactory('hf_dataset_id', root_dir='./local_data')`.","cause":"Attempting to instantiate `DatasetFactory` without providing the required `root_dir` argument, which became mandatory in v0.5.0.","error":"TypeError: DatasetFactory missing 1 required positional argument: 'root_dir'"},{"fix":"Rename the argument: `load_policy(repo_id='your/model')`.","cause":"Using the old argument name `hf_hub_id` instead of `repo_id` for Hugging Face Hub identifiers.","error":"ValueError: The 'hf_hub_id' argument has been removed, please use 'repo_id' instead."},{"fix":"Change the method call to `action = policy.sample_actions(obs)` and ensure `obs` is the current observation.","cause":"Using the deprecated `policy.sample()` method instead of the updated `policy.sample_actions(obs)`.","error":"AttributeError: 'Policy' object has no attribute 'sample'"},{"fix":"Install the library using `pip install lerobot` or activate the correct virtual environment.","cause":"The `lerobot` library is not installed in the current Python environment, or the environment is not activated.","error":"ModuleNotFoundError: No module named 'lerobot'"}]}