Genesis-Embodied-AI/genesis-world · critical · ImportError
'torch' module not available. Please install pytorch manuall
Error message
'torch' module not available. Please install pytorch manually: https://pytorch.org/get-started/locally/
What it means
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.
Source
Thrown at genesis/__init__.py:23
import logging as _logging
import traceback
import weakref
from typing import Callable
from warnings import warn
from contextlib import redirect_stdout
# Import quadrants while collecting its output without printing directly
_qd_outputs = io.StringIO()
os.environ.setdefault("QD_ENABLE_PYBUF", "0" if sys.stdout is sys.__stdout__ else "1")
with redirect_stdout(_qd_outputs):
import quadrants as qd
try:
import torch
except ImportError as e:
raise ImportError(
"'torch' module not available. Please install pytorch manually: https://pytorch.org/get-started/locally/"
) from e
import numpy as np
from .constants import backend as _gs_backend
from .logging import Logger
from .version import __version__
from .utils import redirect_libc_stderr, set_random_seed, get_device
_IS_OLD_TORCH = tuple(map(int, torch.__version__.split(".")[:2])) < (2, 8)
# FIXME: qd.Field does not support zero-copy on Metal for 'torch<=2.9.1'.
# See: https://github.com/pytorch/pytorch/pull/168193
_TORCH_MPS_SUPPORT_DLPACK_FIELD = torch.torch_version.TorchVersion(torch.__version__.split("+", 1)[0]) > (2, 9, 1)
if _IS_OLD_TORCH:
warn("'torch<2.8.0' is not supported. Please upgrade pytorch manually: https://pytorch.org/get-started/locally/")
View on GitHub (pinned to 56e4aa5d82)
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`).
Example fix
# before import genesis # ImportError: 'torch' module not available # after pip install torch import genesis # OK
Defensive patterns
Strategy: validation
Validate before calling
import importlib.util
if importlib.util.find_spec("torch") is None:
raise SystemExit("PyTorch is required. Install it from https://pytorch.org/get-started/locally/")
import genesis Try / catch
try:
import genesis
except ImportError as e:
if "torch" in str(e):
print("Install pytorch first: pip install torch")
raise Prevention
- Pin torch in the same requirements file as genesis.
- Validate the environment with importlib.util.find_spec before importing genesis in deployment scripts.
When it happens
Trigger: `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.
Common situations: 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.
Related errors
- Python module 'uipc' is required by IPCCoupler but is not in
- `morph` in hybrid entity should be either URDF or Mesh
- Cannot handle soft material {material_soft}
- Compounding joints of types 'FREE' or 'FIXED' with any other
- This method has been removed. Please use 'get_AABB()' instea
AI-assisted analysis of Genesis-Embodied-AI/genesis-world@56e4aa5d82 (2026-08-28).
Data as JSON: /api/errors/27ccb05103fab44f.
Report an issue: GitHub.