Install & Compatibility
Where this runs
tested against v3.58.6 · 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.95 runs
installs and imports cleanly · install 0.0s · import 1.594s · 58.5MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 7.4s · import 1.448s · 74MB
67MB installed
● package 67MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Experiment
✓ from comet_ml import Experiment
✗ from comet_ml.experiment import Experiment
While functional, importing directly from the top-level package is the standard and recommended approach.
init
✓ import comet_ml; comet_ml.init()
✗ from comet_ml import init
The `init` function is typically called as a method of the top-level `comet_ml` module, not directly imported.
log_parameters
✓ experiment.log_parameters({'param': value})
✗ comet_ml.log_parameters({'param': value})
Logging functions are methods of an `Experiment` object, not global functions on the `comet_ml` module (unless using the simpler `comet_ml.init()` pattern).
This quickstart demonstrates how to create an `Experiment` using a context manager, log hyperparameters, and track metrics during a simulated training loop. It leverages environment variables for authentication, which is a recommended best practice.
import os
from comet_ml import Experiment
# Ensure COMET_API_KEY and COMET_WORKSPACE are set as environment variables
# or use comet_ml.login() if you prefer interactive login.
# For example: os.environ['COMET_API_KEY'] = 'YOUR_API_KEY'
# os.environ['COMET_WORKSPACE'] = 'YOUR_WORKSPACE'
# Or, for local testing without an explicit API key (results only stored locally):
# experiment = Experiment(project_name="my-test-project", log_code=False, display_summary_to_terminal=False)
# Initialize an experiment
# It's best practice to use a context manager to ensure the experiment terminates correctly
with Experiment(project_name="my-quickstart-project",
api_key=os.environ.get('COMET_API_KEY', None),
workspace=os.environ.get('COMET_WORKSPACE', None),
auto_output_logging='simple', # capture print statements
auto_metric_logging=True, # capture common metrics
log_code=True # logs your script code
) as experiment:
# Log hyperparameters
hyper_params = {"learning_rate": 0.001, "epochs": 10, "batch_size": 32}
experiment.log_parameters(hyper_params)
# Simulate a training loop
for epoch in range(hyper_params["epochs"]):
# Simulate metric calculation
accuracy = 0.5 + (epoch * 0.05) + (hyper_params["learning_rate"] * 100)
loss = 1.0 - (epoch * 0.08) - (hyper_params["learning_rate"] * 50)
# Log metrics for each epoch
experiment.log_metric("accuracy", accuracy, step=epoch)
experiment.log_metric("loss", loss, step=epoch)
# Log a final metric or result
final_accuracy = accuracy # from the last epoch
experiment.log_metric("final_accuracy", final_accuracy)
print(f"Experiment URL: {experiment.url}")
print("Experiment finished.")
comet --version
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'comet_ml'
The `comet-ml` Python package is not installed in the current environment or the environment is not correctly activated.
fixInstall the package using pip: `pip install comet-ml`. If using conda, use `conda install -c anaconda -c conda-forge -c comet_ml comet_ml`.
ImportError: Please import comet before importing these modules: ...
The `comet_ml` library was imported after one of the supported machine learning frameworks (e.g., TensorFlow, PyTorch, Keras, fastai), interfering with Comet's automatic logging hooks.
fixMove `import comet_ml` to the very top of your Python script, before any other machine learning framework imports. Alternatively, disable auto-logging by setting the environment variable `COMET_DISABLE_AUTO_LOGGING=1`.
COMET ERROR: Run will not be logged
The Comet SDK failed to establish an initial connection or handshake with the Comet server, often due to network issues, an incorrect or missing API key, or server downtime.
fixCheck your internet connection and ensure your Comet API key is correctly configured. You can configure it using `comet_ml.login()`, by setting the `COMET_API_KEY` environment variable, or in your `~/.comet.config` file.
AttributeError: 'NoneType' object has no attribute '...' (when interacting with an Experiment object)
The `Experiment` object was not successfully initialized or was prematurely terminated, leading to attempts to call methods on a `None` object.
fixEnsure the `Experiment` object is properly initialized and active before calling its methods. Check for earlier errors that might have prevented `Experiment` creation. Consider using `comet_ml.error_mode()` to get full tracebacks and `comet_ml.get_running_experiment()` to safely retrieve an existing experiment.
Upgrade
Version history
3.58.6latest on PyPI · released Aug 27, 2026
Audit
Dependencies
No dependency data recorded yet.