XTGeo
raw JSON → 4.21.0 verified Fri May 01 auth: no python
XTGeo is a Python library for 3D grids, surfaces, wells, and other geological objects, developed by Equinor. The current version is 4.21.0, requiring Python >=3.11. It is actively maintained with frequent releases (monthly) and provides IO and manipulation for reservoir modelling workflows.
pip install xtgeo Common errors
error ImportError: cannot import name 'Grid' from 'xtgeo' ↓
cause Attempting to import submodule directly (`from xtgeo import Grid`) before xtgeo is fully loaded.
fix
Use
import xtgeo then xtgeo.Grid. error xtgeo.io._grid_io.grid_from_file() got an unexpected keyword argument 'format' ↓
cause The `format` argument was removed in favor of auto-detection from file extension.
fix
Remove the
format parameter; xtgeo now detects format from the file extension. error ModuleNotFoundError: No module named 'xtgeo.xyz' ↓
cause Internal module reorganization; `xtgeo.xyz` no longer exists as a separate subpackage.
fix
Use
xtgeo.points and xtgeo.polygons for point/polygon data, or access via top-level xtgeo.Points. Warnings
breaking Python 3.11+ required; Python <=3.10 no longer supported. ↓
fix Use Python 3.11 or later.
gotcha Do not import submodules directly (e.g., `from xtgeo.grid import Grid`). The top-level `import xtgeo` lazy-loads subpackages; direct imports may break if internal structure changes. ↓
fix Use `import xtgeo` then `xtgeo.Grid`.
deprecated The `tables` dependency was removed in 4.18.0; HDF5 support now uses `h5py`. Code relying on `tables` for reading/writing HDF5 will break. ↓
fix Update code to use `h5py` for HDF5 operations, or pin xtgeo<4.18.0 if `tables` is required.
gotcha File read/write functions expect file-like objects or strings. Passing Path objects may fail due to internal wrapping. ↓
fix Convert Path objects to string with `str(path)` when calling xtgeo file functions.
Imports
- Grid wrong
from xtgeo import Gridcorrectimport xtgeo - Surface wrong
from xtgeo.surface import RegularSurfacecorrectimport xtgeo
Quickstart
import xtgeo
grid = xtgeo.grid_from_file('mygrid.roff')
surf = xtgeo.surface_from_file('mysurf.gri')
print(grid.ncol, grid.nrow, grid.nlay)
print(surf.values.mean())