How to Install optuna in Python

v4.8.0 Data & Science Python >=3.9

A hyperparameter optimization framework

Install pip install optuna

What is optuna?

A hyperparameter optimization framework

Optuna: A hyperparameter optimization framework

| :pagewithcurl: Docs | :gear: Install Guide | :pencil: Tutorial | :bulb: Examples | Twitter | LinkedIn | Medium

Optuna is an automatic hyperparameter optimization software framework, particularly designed for machine learning. It features an imperative, define-by-run style user API. Thanks to our define-by-run API, the code written with Optuna enjoys high modularity, and the user of Optuna can dynamically construct the search spaces for the hyperparameters.

Quick Start

Minimal example to get started with optuna:

import optuna

print(optuna.__version__)

Installation

pip (standard)

pip install optuna

Virtual environment (recommended)

python -m venv venv
source venv/bin/activate   # Windows: venv\Scripts\activate
pip install optuna

pip3

pip3 install optuna

conda

conda install -c conda-forge optuna

Poetry

poetry add optuna

Dependencies

Installing optuna will also install these packages:

Verify the Installation

After installing, confirm the package is available:

python -c "import optuna; print(optuna.__version__)"

If this prints a version number, installation succeeded. If you see a ModuleNotFoundError, see the errors section below.

Installation Errors

Common errors when installing optuna with pip.

ModuleNotFoundError: No module named 'optuna'

Cause: The package is not installed in the current Python environment.

Fix: Run pip install optuna. If using a virtual environment, ensure it is activated first.

ModuleNotFoundError: No module named 'optuna' (installed but still failing)

Cause: pip installed the package into a different Python than the one running your script.

Fix: Use python -m pip install optuna to install into the interpreter you are running.

ImportError: cannot import name 'X' from 'optuna'

Cause: The function or class does not exist in the installed version.

Fix: Check the version with pip show optuna and upgrade with pip install --upgrade optuna.

pip: command not found

Cause: pip is not in PATH or Python was not added to PATH during installation.

Fix: Try python -m pip install optuna. On macOS/Linux try pip3.

PermissionError: [Errno 13] Permission denied

Cause: No write access to the system Python package directory.

Fix: Use a virtual environment, or add --user: pip install --user optuna

SSL: CERTIFICATE_VERIFY_FAILED

Cause: pip cannot verify PyPI's SSL certificate — common behind corporate proxies.

Fix: Try: pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org optuna

MemoryError when loading data

Cause: Dataset is too large to fit in RAM.

Fix: Read in chunks, filter columns on load, or consider Polars/Dask for out-of-core processing.

Recent Releases

VersionReleased
4.8.0 latest 2026-03-16
4.7.0 2026-01-19
4.6.0 2025-11-10
4.5.0 2025-08-18
4.4.0 2025-06-16

Full release history on PyPI →

Manage optuna

Upgrade to latest version

pip install --upgrade optuna

Install a specific version

pip install optuna==4.8.0

Uninstall

pip uninstall optuna

Check what is installed

pip show optuna

Last updated: 2026-04-11 • Data from PyPI