{"record":{"id":"27ccb05103fab44f","repo":"Genesis-Embodied-AI/genesis-world","slug":"torch-module-not-available-please-install-pytor","errorCode":null,"errorMessage":"'torch' module not available. Please install pytorch manually: https://pytorch.org/get-started/locally/","messagePattern":"'torch' module not available\\. Please install pytorch manually: https://pytorch\\.org/get-started/locally/","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"critical","filePath":"genesis/__init__.py","lineNumber":23,"sourceCode":"import logging as _logging\nimport traceback\nimport weakref\nfrom typing import Callable\nfrom warnings import warn\nfrom contextlib import redirect_stdout\n\n# Import quadrants while collecting its output without printing directly\n_qd_outputs = io.StringIO()\n\nos.environ.setdefault(\"QD_ENABLE_PYBUF\", \"0\" if sys.stdout is sys.__stdout__ else \"1\")\n\nwith redirect_stdout(_qd_outputs):\n    import quadrants as qd\n\ntry:\n    import torch\nexcept ImportError as e:\n    raise ImportError(\n        \"'torch' module not available. Please install pytorch manually: https://pytorch.org/get-started/locally/\"\n    ) from e\nimport numpy as np\n\nfrom .constants import backend as _gs_backend\nfrom .logging import Logger\nfrom .version import __version__\nfrom .utils import redirect_libc_stderr, set_random_seed, get_device\n\n\n_IS_OLD_TORCH = tuple(map(int, torch.__version__.split(\".\")[:2])) < (2, 8)\n# FIXME: qd.Field does not support zero-copy on Metal for 'torch<=2.9.1'.\n# See: https://github.com/pytorch/pytorch/pull/168193\n_TORCH_MPS_SUPPORT_DLPACK_FIELD = torch.torch_version.TorchVersion(torch.__version__.split(\"+\", 1)[0]) > (2, 9, 1)\nif _IS_OLD_TORCH:\n    warn(\"'torch<2.8.0' is not supported. Please upgrade pytorch manually: https://pytorch.org/get-started/locally/\")\n\n","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/Genesis-Embodied-AI/genesis-world/blob/56e4aa5d82bdb83f2e532e4cc364cb69527acb06/genesis/__init__.py#L5-L41","documentation":"Genesis hard-depends on PyTorch for its tensor pipeline, so genesis/__init__.py imports torch right after quadrants at package import time. If the import raises ImportError, it is re-raised with an actionable message pointing at PyTorch's install wizard. Hitting it means the active Python environment simply has no usable torch install.","triggerScenarios":"`import genesis` (or anything importing it) in a Python environment where `pip install torch` was never run, where torch is installed for a different interpreter/conda env, or where a broken torch install raises ImportError on load.","commonSituations":"Fresh clone of Genesis used with an incomplete `pip install -e .` that skipped torch; wrong conda env activated; system pip vs virtualenv mismatch; CUDA-incompatible torch wheel failing to import on machines without the right CUDA runtime.","solutions":["Install PyTorch for your platform: `pip install torch` (CPU) or the CUDA wheel from https://pytorch.org/get-started/locally/.","Verify you are in the same interpreter Genesis uses: `python -c \"import torch; print(torch.__version__)\"`.","If torch is installed but fails to import, reinstall the wheel matching your CUDA/Python version (`pip install --force-reinstall torch`)."],"exampleFix":"# before\nimport genesis  # ImportError: 'torch' module not available\n\n# after\npip install torch\nimport genesis  # OK","handlingStrategy":"validation","validationCode":"import importlib.util\nif importlib.util.find_spec(\"torch\") is None:\n    raise SystemExit(\"PyTorch is required. Install it from https://pytorch.org/get-started/locally/\")\nimport genesis","typeGuard":null,"tryCatchPattern":"try:\n    import genesis\nexcept ImportError as e:\n    if \"torch\" in str(e):\n        print(\"Install pytorch first: pip install torch\")\n    raise","preventionTips":["Pin torch in the same requirements file as genesis.","Validate the environment with importlib.util.find_spec before importing genesis in deployment scripts."],"tags":["python","pytorch","missing-dependency","installation"],"backgroundTag":"missing-dependency","analyzedSha":"56e4aa5d82bdb83f2e532e4cc364cb69527acb06","analyzedAt":"2026-08-28T15:15:07.922Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}