Optional dependencies¶
pip install hypertools installs everything the core functionality needs:
plotting with matplotlib, dimensionality reduction, alignment, clustering,
normalization, Kalman/ARIMA forecasting, and missing-data imputation. The
heavier model families are declared as pip extras of hypertools in
pyproject.toml. You can install them ahead of time, or let hypertools
install them the first time a call needs one.
The extras¶
Extra |
Installs |
What it adds |
|---|---|---|
|
plotly, kaleido |
the interactive backend: |
|
pydata-wrangler[hf] (torch, transformers, sentence-transformers, tokenizers, datasets) |
Hugging Face text embeddings, e.g.
|
|
skaters |
the |
|
chronos-forecasting |
the Hugging Face |
|
torch |
the six autoencoder reducers ( |
|
gensim |
|
|
kagglehub |
|
|
pylsl |
|
|
scikit-image |
smooth 3-D |
|
openpyxl |
|
Extras combine: pip install "hypertools[interactive,torch]". The dev
extra holds the test and development dependencies and is not installed on
demand.
Installation on demand¶
You do not have to install an extra before using the feature it provides.
The first call that needs a missing optional package installs that extra’s
requirements into the running interpreter (python -m pip install ...,
using the requirement strings hypertools declares in pyproject.toml),
prints a one-line notice, and carries on:
hypertools: installing plotly>=6.1.1, kaleido>=1.0 (needed for the plotly backend) ...
Only the extra’s own requirements are installed. hypertools itself is never reinstalled, so an editable or branch install stays exactly as it is.
If the install fails (no network, no permission to write to the
environment), the call raises ImportError naming the manual command,
e.g. pip install "hypertools[interactive]".
An extra that is installed but too old¶
pip install "hypertools[interactive]" always resolves versions that
work together. An environment that already held an older copy of one of
those packages (a notebook image with an older plotly, say) may not. So an
installed extra is also checked, once per process, against the requirements
hypertools declares, and every package of the extra is checked, because a
feature needs them together: kaleido 1.x cannot export a static image with
a plotly older than 6.1.1.
A package below its declared requirement is upgraded the same way a missing one is installed, with a notice naming the installed version and the requirement:
hypertools: upgrading plotly 5.24.1 to plotly>=6.1.1 (needed for the plotly backend) ...
This happens only while that package has not been imported yet. Python
cannot replace a package that is already imported in a running process, so
if your code (or another library) imported the old version first, nothing
is installed and the call raises ImportError:
plotly 5.24.1 is installed, but hypertools needs plotly>=6.1.1 (needed
for the plotly backend). plotly is already imported in this Python
process, so hypertools did not upgrade it in place. Run `pip install
"hypertools[interactive]"` and restart Python (in a notebook, restart
the kernel or runtime).
With installation turned off (below) the call raises ImportError with
the same three facts: the installed version, the requirement, and the
command. That command upgrades the extra’s packages and leaves hypertools
itself as it is. With backend='auto' (the default), where plotly is
chosen only because the environment has it, a plotly that is too old and
cannot be upgraded produces a warning with that message and the plot is
drawn with matplotlib instead.
A development or pre-release build of the required version (6.1.1.dev0,
6.1.1rc1) counts as that version, and a package whose version cannot be
read (an untagged source build reporting 0+unknown) is never reported
as too old.
Turning it off¶
Call hypertools.set_autoinstall(False). A missing extra, or one that
is installed but older than hypertools requires, then raises
ImportError with the manual pip install "hypertools[<extra>]"
command, and nothing is installed or upgraded. It works like
set_interactive_backend: called directly it applies to the rest of the
session (set_autoinstall(True) turns installation back on), and used
with with it applies to one block:
import hypertools as hyp
hyp.set_autoinstall(False) # for the rest of the session
with hyp.set_autoinstall(False): # for one block
hyp.predict(data, model='Chronos', t=5) # ImportError if missing
This is the setting for locked-down environments and anywhere pip should
not run inside a Python process. Where no Python runs before hypertools is
imported (a CI image built ahead of time), the environment variable
HYPERTOOLS_AUTO_INSTALL=0 (false, no and off also work)
sets the starting value; a set_autoinstall call overrides it.
The setting is process-global (shared by every thread; the newest call
still in force decides, and a with block removes only its own setting
on exit), and it also reaches the subprocess that renders a plotly
animation’s frames for export, which starts from the parent’s effective
value, whichever of the two set it. That export raises ImportError
naming the manual command when kaleido is missing and installation is off,
like any other call.
Chrome for static plotly export¶
Interactive plotly output (HTML, notebooks) needs no browser. Exporting a plotly figure to PNG/PDF, or saving a plotly animation to a GIF or video, goes through kaleido, which renders each frame in a headless Chrome. The first such export checks that kaleido can render and, when it cannot, provisions what is missing:
on Debian/Ubuntu images that lack them (a fresh Colab or Kaggle kernel), the four system libraries Chrome needs to start –
libatk1.0-0,libatk-bridge2.0-0,libatspi2.0-0andlibxcomposite1– viaapt-get. This step runs only when the process is root or has password-lesssudo; otherwise it is skipped.a Chrome build for kaleido (about 150 MB), via
plotly.io.get_chrome().
Both steps print a one-line hypertools: notice, and both are
skipped after set_autoinstall(False). When no working Chrome could be
provided, the export raises HypertoolsIOError with the commands to run
yourself: import plotly.io as pio; pio.get_chrome() and, on
Debian/Ubuntu, apt-get install -y libatk1.0-0 libatk-bridge2.0-0
libatspi2.0-0 libxcomposite1. Installing Chrome or Chromium through your
system’s package manager also works, and so does saving the figure with the
matplotlib backend instead (backend='matplotlib').
Pre-installing everything¶
To fetch every optional package up front (for an offline machine, a Docker image, or a CI runner), list the extras you want in one install:
pip install "hypertools[interactive,text,predict,predict-hf,torch,gensim,kaggle,lsl,density3d,io]"
Chrome is not a pip package; to pre-provision it for static plotly export,
run python -c "import plotly.io as pio; pio.get_chrome()" after the
install (and the apt-get line above on a bare Debian/Ubuntu image).