{"id":4125,"library":"mujoco","title":"MuJoCo Physics Simulator","description":"MuJoCo (Multi-Joint dynamics with Contact) is a physics engine developed by Google DeepMind, used for research and development in robotics, biomechanics, and other areas. The Python bindings allow programmatic interaction with models, simulation, and data. It releases frequently, with minor version updates typically every few weeks to months.","status":"active","version":"3.6.0","language":"en","source_language":"en","source_url":"https://github.com/google-deepmind/mujoco","tags":["physics","simulation","robotics","deepmind","reinforcement-learning"],"install":[{"cmd":"pip install mujoco","lang":"bash","label":"Install official MuJoCo Python bindings"}],"dependencies":[],"imports":[{"note":"The `mujoco_py` library is deprecated and unmaintained; use the official `mujoco` package.","wrong":"import mujoco_py","symbol":"mujoco","correct":"import mujoco"},{"symbol":"MjModel","correct":"import mujoco\nmodel = mujoco.MjModel.from_xml_string(...)"},{"symbol":"MjData","correct":"import mujoco\ndata = mujoco.MjData(model)"},{"symbol":"mj_step","correct":"import mujoco\nmujoco.mj_step(model, data)"}],"quickstart":{"code":"import mujoco\nimport numpy as np\n\n# Create a simple XML model string for a sphere on a plane\nxml_string = \"\"\"\n<mujoco model=\"sphere_drop\">\n  <worldbody>\n    <geom name=\"floor\" type=\"plane\" size=\"0 0 0.1\" material=\"grid\"/>\n    <body name=\"sphere\" pos=\"0 0 1\">\n      <geom name=\"ball\" type=\"sphere\" size=\"0.1\" material=\"sphere_mat\"/>\n    </body>\n  </worldbody>\n  <asset>\n    <texture type=\"2d\" name=\"grid\" builtin=\"checker\" width=\"512\" height=\"512\" rgb1=\"0.1 0.2 0.3\" rgb2=\"0.2 0.3 0.4\" mark=\"edge\" markrgb=\"0.8 0.8 0.8\"/>\n    <material name=\"grid\" texture=\"grid\" texrepeat=\"1 1\" texuniform=\"true\"/>\n    <material name=\"sphere_mat\" rgba=\"0.7 0 0 1\"/>\n  </asset>\n</mujoco>\n\"\"\"\n\n# Load the model and create data\nmodel = mujoco.MjModel.from_xml_string(xml_string)\ndata = mujoco.MjData(model)\n\n# Simulate for 100 steps\nprint(f\"Initial sphere position: {data.qpos[2]:.3f}\") # Assuming Z is the 3rd element of qpos\nfor i in range(100):\n    mujoco.mj_step(model, data)\n\nprint(f\"Final sphere position: {data.qpos[2]:.3f}\")","lang":"python","description":"This example loads a basic XML model of a sphere dropping onto a plane and simulates it for 100 steps, printing its initial and final vertical position. It demonstrates the core `MjModel`, `MjData`, and `mj_step` functionalities."},"warnings":[{"fix":"Uninstall `mujoco_py` and `pip install mujoco`. Rewrite code to use the new `mujoco` API. Consult official documentation for API changes.","message":"The official `mujoco` Python package (maintained by Google DeepMind) replaced the community-developed `mujoco_py`. `mujoco_py` is deprecated, unmaintained, and should not be used in new projects.","severity":"breaking","affected_versions":"All versions of `mujoco` (from 2.0.0 onwards) when migrating from `mujoco_py`."},{"fix":"Carefully review the official changelog (e.g., for `3.0.0`) and update API calls according to the new design. Many module structures and function signatures have changed.","message":"MuJoCo 3.0.0 introduced a substantial redesign of the Python Bindings API. Code written for pre-3.0 versions will likely break, especially regarding `mjx` (JAX integration) and `mjcf` (model construction) utilities.","severity":"breaking","affected_versions":"Versions `mujoco < 3.0.0` when upgrading to `mujoco >= 3.0.0`."},{"fix":"Install `mujoco_viewer` (`pip install mujoco_viewer`) and use its API for basic visualization, or integrate with a full environment framework like `dm_control` for more advanced rendering and control.","message":"The `mujoco` Python package itself does not include a visualizer. To render simulations, you typically need to install an additional library like `mujoco_viewer` or integrate with `dm_control`.","severity":"gotcha","affected_versions":"All versions."},{"fix":"Ensure your Python environment is version 3.10 or newer. Use `python --version` to check and upgrade if necessary.","message":"The `mujoco` Python package officially requires Python 3.10 or newer. Installing with older Python versions may lead to errors or unexpected behavior due to incompatibility with the pre-compiled binaries.","severity":"gotcha","affected_versions":"All versions `>= 3.0.0`."}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}