Skip to main content

How to Install TensorFlow with uv

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

TensorFlow is Google's open-source library for machine learning, and Keras, the library you build models with, comes with it. This guide installs both into a uv project with one command, then checks that they work, with TensorFlow 2.22.0 and Keras 3.15.1 on Python 3.14.

Syntax​

Syntax
uv add tensorflow
PartWhat it means
uv addAdds a package to the project in the current folder, and records it in pyproject.toml and uv.lock
tensorflowTensorFlow's package on PyPI. It brings Keras, NumPy and the rest of what TensorFlow needs

The TensorFlow 2.22.0 release notes say it "Added official support for Python 3.14 (cp314) across Linux, macOS, and Windows (supporting Python 3.10–3.14)".

The Example​

A new project, tensorflow-demo, gets TensorFlow, then reports the version it got and runs a small calculation.

Prerequisites​

  • uv. This guide uses uv 0.13.10. It downloads Python 3.14 for you if your computer doesn't have it.
  • About 1.5 GB of free disk space. The project's packages took 1.4 GB here.

Step 1: Create the Project on Python 3.14​

Terminal
uv init --python 3.14 tensorflow-demo
cd tensorflow-demo
Output
Initialized project `tensorflow-demo` at `/Users/you/source/tensorflow-demo`

The terminal after uv init --python 3.14 tensorflow-demo: Initialized project tensorflow-demo at /Users/you/source/tensorflow-demo.

Why 3.14 and not the newer 3.15? TensorFlow 2.22.0 publishes packages for Python 3.10 to 3.14 only, so on 3.15 uv add tensorflow fails. Fixed: "all versions of tensorflow have no wheels with a matching Python version tag (e.g., cp315)" shows that error and the fix.

Step 2: Add TensorFlow​

Terminal
uv add tensorflow
Output
Using CPython 3.14.10
Creating virtual environment at: .venv
Resolved 32 packages in 1.84s
Built tensorflow-demo @ file:///Users/you/source/tensorflow-demo
Prepared 32 packages in 26.98s
Installed 32 packages in 239ms
+ absl-py==2.5.1
+ astunparse==1.6.3
+ certifi==2026.11.20
+ charset-normalizer==3.5.3
+ flatbuffers==25.12.19
+ gast==0.7.0
+ google-pasta==0.2.0
+ grpcio==1.86.0
+ h5py==3.15.1
+ idna==3.20
+ keras==3.15.1
+ libclang==18.1.1
+ markdown-it-py==4.3.0
+ mdurl==0.1.2
+ ml-dtypes==0.7.0
+ namex==0.1.0
+ numpy==2.5.5
+ opt-einsum==3.4.0
+ optree==0.20.0
+ packaging==26.4
+ protobuf==7.36.2
+ pygments==2.21.0
+ requests==2.34.2
+ rich==15.0.0
+ six==1.17.0
+ tensorflow==2.22.0
+ tensorflow-demo==0.1.0 (from file:///Users/you/source/tensorflow-demo)
+ termcolor==3.3.0
+ typing-extensions==4.16.0
+ urllib3==2.8.0
+ wheel==0.48.0
+ wrapt==2.5.2

The terminal after uv add tensorflow: uv used CPython 3.14.10, created .venv, resolved 32 packages, prepared them in 26.98 seconds and installed 32, including keras 3.15.1, numpy 2.5.5, h5py 3.15.1, protobuf 7.36.2 and tensorflow 2.22.0.

uv created the project's virtual environment, .venv, and installed 32 packages: TensorFlow, the 30 packages it needs, and the project itself. A few of them matter later:

PackageWhat it does
kerasThe library you build and train models with. TensorFlow 2.22.0 comes with Keras 3
numpyArrays of numbers. TensorFlow turns them into tensors and back
h5pyReads and writes HDF5 files, an older format for saved models
protobufThe format TensorFlow uses for saved models and graphs

TensorBoard, TensorFlow's training dashboard, isn't in the list. The release notes for 2.22.0 explain: "The TensorBoard dependency is no longer included by default." Add it with uv add tensorboard when you need it.

Step 3: Check the Version​

Terminal
uv run python -c "import tensorflow as tf; print(tf.__version__)"
Output
2.22.0

The terminal after the version check: 2.22.0.

This command took 39 seconds on an M1 Pro: the first time TensorFlow loads in a new environment, it's slow. The same command, run again, took 4 seconds.

Step 4: Run TensorFlow's Own Check​

The TensorFlow installation guide verifies an installation with this line. It adds up a million random numbers:

Terminal
uv run python -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
Output
tf.Tensor(-318.15567, shape=(), dtype=float32)

The terminal after TensorFlow's check: tf.Tensor(-318.15567, shape=(), dtype=float32).

tf.random.normal([1000, 1000]) made a 1,000 by 1,000 table of random numbers, and tf.reduce_sum added them up. Your number will be different, because the numbers are random. What matters is that a tf.Tensor came back: TensorFlow works. The commands on this page work unchanged in PowerShell.

A GPU on Linux or Windows​

On this Mac, TensorFlow runs on the CPU: the installation guide says "There is currently no official GPU support for MacOS." On Linux with an NVIDIA GPU, the guide installs tensorflow[and-cuda], which in a uv project is uv add "tensorflow[and-cuda]". On Windows, it warns that "TensorFlow 2.10 was the last TensorFlow release that supported GPU on native-Windows", and points to WSL2. I haven't run either here: this Mac has no NVIDIA GPU.

Common Mistakes​

MistakeWhat happensDo this instead
Creating the project on Python 3.15uv add tensorflow fails: TensorFlow 2.22.0 has no packages for 3.15Use --python 3.14
Running python -c "import tensorflow" outside the projectModuleNotFoundError: No module named 'tensorflow', unless your system Python has its own copy: the package is in the project's .venvRun it through uv run from the project folder
Thinking the first import has hungIt's slow once per new environment: 39 seconds hereWait for it; the next import is quick

FAQ​

Do I need to install Keras separately?​

No. uv add tensorflow installed Keras 3.15.1 with it, and import keras works straight away.

Can I use pip instead of uv?​

Yes. The installation guide uses pip install tensorflow. uv adds a project, a lock file and a pinned Python version, which keeps installs repeatable.

Conclusion​

uv add tensorflow installed TensorFlow 2.22.0 and Keras 3.15.1 into a Python 3.14 project. The version check printed 2.22.0, and TensorFlow's own check returned a tensor.

Additional Resources​