Packages and environments

SteelPython uses pip and venv as CPython does, and installs the same packages from the same place, the Python Package Index. If you know python -m pip and python -m venv, you know this page already; it mostly points out what to expect.

Installing packages

spy -m pip install requests
spy -m pip install "pandas>=2" matplotlib
spy -m pip install -r requirements.txt
spy -m pip list
spy -m pip uninstall requests

Everything in pip's documentation applies: requirement files, constraints, --index-url and --extra-index-url, pip download, pip wheel, proxies (HTTPS_PROXY), and certificates (--cert, PIP_CERT; the Windows certificate store is used by default).

Installing for yourself

When SteelPython is installed for all users of the machine, its own site-packages folder is not writable without administrator rights. As with CPython, pip then installs into your per-user folder instead, %APPDATA%\SteelPython\Python312\site-packages, and says so ("Defaulting to user installation because normal site-packages is not writeable"); spy -m pip install --user ... asks for that folder explicitly. The packages are available to you in every spy you run. Commands they install go to %APPDATA%\SteelPython\Python312\Scripts: add that folder to your PATH, or run them through spy, as in spy -m IPython. To install for everyone, run pip from an administrator terminal. A virtual environment avoids the question altogether.

Binary wheels

SteelPython runs CPython 3.12's compiled extension modules, so pip installs the same wheels CPython 3.12 uses: the cp312-win_amd64 and abi3 wheels on PyPI. numpy, pandas, scipy, scikit-learn, matplotlib, pyarrow, polars, duckdb, lxml, cryptography, pydantic, orjson and the rest install in seconds, with nothing to compile, exactly as they do for CPython.

Among the packages known to work: numpy, pandas, scipy, scikit-learn, statsmodels, seaborn, matplotlib, PyTorch, Keras, transformers, numba, polars, pyarrow, duckdb, streamlit, Flask, FastAPI (with uvicorn), Django, SQLAlchemy, requests, httpx, aiohttp, pydantic, cryptography, lxml, Pillow, grpcio, protobuf, greenlet and gevent, pytest, mypy and black.

PyTorch on the GPU

PyTorch's CUDA builds come from PyTorch's own index; install them as its Get Started page says, with spy for python:

spy -m pip install torch --index-url https://download.pytorch.org/whl/cu128
spy -c "import torch; print(torch.cuda.is_available(), torch.cuda.get_device_name(0))"

These wheels are over 2 GB; pip downloads and caches them as usual.

Virtual environments

Give each project its own environment, as you would with CPython (venv's documentation):

spy -m venv .venv
.venv\Scripts\activate
spy -m pip install -r requirements.txt
spy main.py
deactivate

In PowerShell, activate with .venv\Scripts\Activate.ps1. An environment holds its own spy.exe in Scripts\, and its packages in Lib\site-packages; without activating, run .venv\Scripts\spy.exe directly. Commands installed by packages (pytest, black, streamlit, ...) land in Scripts\ too and work by name once the environment is active.

Misp and Spy Notebook find the environments in your project folder (.venv, venv, env) and can create one for you, with pip in it.

Environments made by SteelPython are SteelPython's: a .venv created by CPython cannot be used by spy, and the other way round. Create a separate one, from the same requirements.txt.

Building packages from source

Some packages have no wheel for Windows, or you may want to build one yourself (pip install --no-binary, or a package of your own with C code). As with CPython on Windows, that needs a C compiler: install the Microsoft C++ Build Tools (the Desktop development with C++ workload). SteelPython carries the headers and libraries a build needs (Include\ and libs\ beside spy.exe), and build backends such as setuptools find them where they look for CPython's. Writing extensions walks through a small example.

Packages written in pure Python never need a compiler.

When a package does not work

Most of PyPI works, but a package can depend on something SteelPython does not have:

  • Tk: anything that imports tkinter (some plotting backends, simple GUI helpers). For matplotlib, use a non-Tk backend: MPLBACKEND=Agg to save figures to files, or show them in Spy Notebook.
  • CPython's internals: a package that reads interpreter structures directly, rather than through the C API (some profilers and debuggers that inspect frames in native code, bytecode rewriters), may fail to import or behave oddly.
  • Reference-count timing: a package whose tests or logic expect an object to be freed at its last reference (see Differences from CPython).

If a package fails, the error usually says why. Reports of packages that misbehave are welcome at contact@methodox.io.