Install & Compatibility
Where this runs
tested against v3.46.0.11 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 1.082s · 293.9MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 6.5s · import 0.875s · 294MB
292MB installed
● package 292MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
H2OFrame
✓ from h2o import H2OFrame
H2OFrame is also commonly accessed as `h2o.H2OFrame` after `import h2o`.
This quickstart initializes a local H2O cluster, converts a Pandas DataFrame into an H2OFrame, trains a Gradient Boosting Machine (GBM) model, makes predictions, and demonstrates proper shutdown of the H2O cluster. Pay close attention to data type conversions (e.g., `asfactor()`) and cluster resource management.
import h2o
from h2o.estimators.gbm import H2OGradientBoostingEstimator
import pandas as pd
# Initialize H2O cluster (adjust max_mem_size based on your system's RAM and data size)
h2o.init(max_mem_size="4G", nthreads=-1)
# Create a sample Pandas DataFrame
data = {
'feature1': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
'feature2': [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],
'target': [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]
}
df_pandas = pd.DataFrame(data)
# Convert Pandas DataFrame to H2OFrame
df_h2o = h2o.H2OFrame(df_pandas)
# Convert target to factor for classification problems
df_h2o['target'] = df_h2o['target'].asfactor()
# Define predictors and response variables
predictors = ['feature1', 'feature2']
response = 'target'
# Split data into training and testing sets
train, test = df_h2o.split_frame(ratios=[0.7], seed=42)
# Build a Gradient Boosting Machine (GBM) model
gbm_model = H2OGradientBoostingEstimator(
ntrees=50,
max_depth=5,
seed=42
)
gbm_model.train(x=predictors, y=response, training_frame=train)
# Make predictions on the test set
predictions = gbm_model.predict(test)
print("\nPredictions on test data (first 5 rows):\n")
print(predictions.head())
# Shutdown H2O cluster (crucial for resource management)
h2o.shutdown(prompt=False)
Debug
Known issues
gotchaH2O requires a Java Runtime Environment (JRE) (Java 8 or higher is recommended) to operate its backend cluster. Ensure Java is installed and its executable is accessible in your system's PATH. Without a compatible JRE, `h2o.init()` will fail to start the cluster.fixInstall a compatible JRE (e.g., OpenJDK 8 or 11). Verify installation by running `java -version` in your terminal.
affects: All H2O-3 versions
gotchaThe H2O JVM process, started by `h2o.init()`, defaults to allocating 1GB of Java heap space. For larger datasets or complex models, this is often insufficient, leading to `java.lang.OutOfMemoryError`. You must explicitly allocate enough memory.fixIncrease memory allocation during initialization using `max_mem_size`: `h2o.init(max_mem_size='8G')` (adjust '8G' based on your system's available RAM and data size).
affects: All H2O-3 versions
gotchaH2O DataFrames (`h2o.H2OFrame`) are distinct from Pandas DataFrames. Direct operations attempting to mix them or use Pandas methods on an H2OFrame (or vice-versa) will result in errors. Explicit conversion is always required.fixConvert Pandas to H2OFrame using `h2o.H2OFrame(pandas_df)`. Convert H2OFrame to Pandas using `h2o_frame.as_data_frame()`.
affects: All H2O-3 versions
gotchaWhen `h2o.init()` starts a local H2O cluster, it consumes system resources. Failing to call `h2o.shutdown()` at the end of your H2O session (especially in scripts or notebooks) can leave lingering Java processes, leading to resource leaks or port conflicts.fixAlways call `h2o.shutdown(prompt=False)` at the end of your H2O session to cleanly terminate the cluster and release resources.
affects: All H2O-3 versions
Errors
Common errors & fixes
h2o.exceptions.H2OConnectionError: H2O connection broken!
The H2O cluster failed to start or unexpectedly disconnected, often due to a missing/incompatible JRE, insufficient memory, or a port conflict.
fixEnsure Java 8+ is installed and in PATH. Increase `max_mem_size` in `h2o.init()`. If starting multiple clusters, specify a unique `port`, e.g., `h2o.init(port=54321)`.
java.lang.OutOfMemoryError: Java heap space
The H2O JVM process ran out of allocated memory while attempting to store data or build a model. The default 1GB is often insufficient.
fixIncrease the maximum memory size for the H2O cluster during initialization: `h2o.init(max_mem_size='8G')` (adjust '8G' to a suitable value based on your system's available RAM).
AttributeError: 'pandas.core.frame.DataFrame' object has no attribute 'asfactor'
You are attempting to use an H2OFrame-specific method (like `.asfactor()`, `.split_frame()`, etc.) directly on a Pandas DataFrame.
fixConvert your Pandas DataFrame to an H2OFrame first: `h2o_frame = h2o.H2OFrame(pandas_df)`.
ModuleNotFoundError: No module named 'h2o'
The `h2o` Python package is not installed in your current Python environment.
fixInstall the package using pip: `pip install h2o`.
Upgrade
Version history
3.46.0.11latest on PyPI · released May 22, 2026
Audit
Dependencies
No dependency data recorded yet.