{"id":7186,"library":"dm-control","title":"DM-Control","description":"DM-Control is a Python library from Google DeepMind that provides continuous control environments and Python bindings for the MuJoCo physics engine. It's widely used in reinforcement learning research for creating and interacting with physically realistic simulated agents. The library is actively maintained with frequent releases, often tied to updates in the underlying MuJoCo engine.","status":"active","version":"1.0.39","language":"en","source_language":"en","source_url":"https://github.com/google-deepmind/dm_control","tags":["reinforcement-learning","robotics","simulation","mujoco","deepmind","control"],"install":[{"cmd":"pip install dm-control","lang":"bash","label":"Stable Release"},{"cmd":"sudo apt-get install libglfw3\n# Or equivalent for your OS, e.g., brew install glfw for macOS\npip install dm-control[viewer]","lang":"bash","label":"With Viewer Support (requires system GLFW)"}],"dependencies":[{"reason":"Bundled C++ library, core physics engine functionality. Python package 'mujoco' is separate but can be installed alongside for direct MuJoCo API access.","package":"mujoco","optional":false},{"reason":"Required for rendering with the dm_control.viewer module.","package":"glfw","optional":true},{"reason":"Used for command-line parsing and logging utilities.","package":"absl-py","optional":false},{"reason":"Core numerical operations for array manipulation.","package":"numpy","optional":false}],"imports":[{"note":"Provides access to standard control environments like 'cartpole' or 'walker'.","symbol":"suite","correct":"from dm_control import suite"},{"note":"Base class for RL environments, though usually not instantiated directly for standard suite tasks.","symbol":"Environment","correct":"from dm_control.rl import control"},{"note":"Physics object for low-level interaction with MuJoCo models. Often confused with the top-level package.","wrong":"from dm_control import Physics","symbol":"Physics","correct":"from dm_control.mujoco import Physics"},{"note":"Module for visualizing MuJoCo environments.","symbol":"viewer","correct":"from dm_control import viewer"}],"quickstart":{"code":"import os\nfrom dm_control import suite\nfrom dm_control import viewer\n\n# Load a standard control environment\nenv = suite.load(domain_name=\"cartpole\", task_name=\"balance\")\n\n# Create a viewer application\n# Note: Requires system-level GLFW installation for the viewer to work\n# e.g., `sudo apt-get install libglfw3` on Linux or `brew install glfw` on macOS\nif os.environ.get('DM_CONTROL_NO_VIEWER') != 'true':\n    try:\n        viewer.launch(env)\n    except Exception as e:\n        print(f\"Could not launch viewer: {e}\")\n        print(\"Try running without viewer by setting environment variable DM_CONTROL_NO_VIEWER=true\")\n        print(\"Or ensure GLFW is installed: `pip install dm-control[viewer]` and system-level `libglfw3`.\")\nelse:\n    print(\"Viewer explicitly disabled via DM_CONTROL_NO_VIEWER environment variable.\")\n    # Or, manually step through the environment:\n    # action_spec = env.action_spec()\n    # time_step = env.reset()\n    # while not time_step.last():\n    #     action = 0.0 # Example: apply zero action\n    #     time_step = env.step(action)","lang":"python","description":"This quickstart loads the 'cartpole/balance' environment and attempts to launch the interactive viewer. The viewer requires the `dm-control[viewer]` extra and a system-wide GLFW installation (e.g., `libglfw3` on Linux). If GLFW is not set up, the viewer might fail, but the environment can still be interacted with programmatically."},"warnings":[{"fix":"Install GLFW development libraries for your operating system (e.g., `sudo apt-get install libglfw3` on Debian/Ubuntu, `brew install glfw` on macOS) and then `pip install dm-control[viewer]`.","message":"Rendering with `dm_control.viewer` typically requires a system-level GLFW installation, not just `pip install glfw`. Without it, you will encounter `GLFWError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Pin `dm-control` to a specific version for critical projects. If using custom MuJoCo models, thoroughly test after any `dm-control` upgrade. Consult the `dm-control` GitHub releases for bundled MuJoCo versions.","message":"DM-Control bundles a specific version of the MuJoCo physics engine. Upgrading `dm-control` can introduce a new MuJoCo version, potentially causing subtle behavioral changes or API incompatibilities if you are interacting with MuJoCo models at a low level via `dm_control.mujoco`.","severity":"breaking","affected_versions":"All versions, especially across minor/patch releases with MuJoCo upgrades (e.g., 1.0.38 to 1.0.39 upgraded MuJoCo 3.6.0 to 3.7.0)."},{"fix":"Understand the scope: use `dm_control.suite` for high-level tasks, and `dm_control.mujoco` for advanced MuJoCo integration within `dm-control`'s framework. Only use the standalone `mujoco` package if you need direct, low-level MuJoCo API access independent of `dm-control`'s abstractions.","message":"The `mujoco` PyPI package provides direct Python bindings to MuJoCo, separate from the `dm-control` library. While both use MuJoCo, they serve different purposes: `dm-control` focuses on control environments, while `mujoco` provides raw physics engine access. Using both might lead to confusion regarding which MuJoCo version is active.","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":"Install the GLFW development libraries for your OS (e.g., `sudo apt-get install libglfw3-dev` on Linux, `brew install glfw` on macOS). Ensure you have also installed `dm-control` with viewer extras: `pip install dm-control[viewer]`.","cause":"The GLFW graphics library is not correctly installed or configured on your system, preventing the `dm_control.viewer` from initializing.","error":"GLFWError: Failed to initialize GLFW"},{"fix":"Ensure `dm-control` is installed: `pip install dm-control`. Verify your Python environment is active and `pip` is installing into the correct one.","cause":"The `dm-control` package is not installed or not available in your Python environment.","error":"ModuleNotFoundError: No module named 'dm_control.suite'"},{"fix":"Ensure you are using the MuJoCo version bundled with `dm-control` which does not require a license. If you're manually managing MuJoCo, upgrade to MuJoCo 2.1 or newer, or place a valid `mjkey.txt` in the specified location for older versions. Most users of `dm-control` will not encounter this directly unless they have custom MuJoCo setups.","cause":"For older MuJoCo versions (before 2.1), a license file was required. While `dm-control` bundles modern MuJoCo, if you are attempting to use an older local MuJoCo installation or custom build, this error can appear.","error":"mujoco.FatalError: Could not find license file at /path/to/.mujoco/mjkey.txt"}]}