Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
flwr
✓ import flwr
✗ import flower
The package is imported as flwr, not flower.
NumPyClient
✓ from flwr.client import NumPyClient
✗ from flwr.client import NumPyClient
Correct as shown; older versions used flwr.client.NumPyClient
Strategy
✓ from flwr.server import Strategy
✗ from flwr.server.strategy import Strategy
Strategy is available directly under flwr.server (not .strategy)
Quickstart example: a Flower client using NumPyClient with TensorFlow.
import flwr as fl
import tensorflow as tf
# Define a simple client
class CifarClient(fl.client.NumPyClient):
def __init__(self):
self.model = tf.keras.applications.ResNet50(weights=None, input_shape=(32,32,3), classes=10)
self.model.compile('adam', 'sparse_categorical_crossentropy', metrics=['accuracy'])
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.cifar10.load_data()
self.x_train, self.y_train = x_train.astype('float32')/255, y_train
self.x_test, self.y_test = x_test.astype('float32')/255, y_test
def get_parameters(self, config):
return self.model.get_weights()
def fit(self, parameters, config):
self.model.set_weights(parameters)
self.model.fit(self.x_train, self.y_train, epochs=1, verbose=0)
return self.model.get_weights(), len(self.x_train), {}
def evaluate(self, parameters, config):
self.model.set_weights(parameters)
loss, acc = self.model.evaluate(self.x_test, self.y_test, verbose=0)
return loss, len(self.x_test), {'accuracy': acc}
# Start client
fl.client.start_numpy_client(server_address='127.0.0.1:8080', client=CifarClient())
Debug
Known issues
breakingNightly builds may introduce breaking changes without notice. Do not use in production or as a pinned dependency for reproducible experiments.fixUse stable release flwr instead for production. Pin a specific nightly if needed, but expect instability.
affects: all nightly versions
deprecatedThe legacy strategy API (e.g., flwr.server.strategy.FedAvg) is being replaced by the Message API. In nightly builds, some strategies may be removed or renamed.fixUse the new Message API strategies from flwr.server.strategy (e.g., FedAvgMessage). Refer to migration guide.
affects: >=1.30.0.dev
gotchaInstalling flwr-nightly may conflict with a stable flwr installation. pip may uninstall flwr in favor of flwr-nightly.fixUse a virtual environment to isolate nightly builds. Do not install both flwr and flwr-nightly in the same environment.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'flwr'
Installed flwr-nightly but tried to import flwr. The package provides the flwr module, but pip may have named it differently? Actually, flwr-nightly provides the flwr module, so this error occurs if flwr is not installed and flwr-nightly is also missing.
fixRun `pip install flwr-nightly` to install the nightly build.
AttributeError: module 'flwr' has no attribute 'client'
In very old versions or if using a broken nightly, the client submodule may not be imported automatically.
fixUse explicit import: `from flwr import client` or `import flwr.client`.
ImportError: cannot import name 'NumPyClient' from 'flwr.client'
NumPyClient was renamed to something else in nightly builds (e.g., Client). Check the current API.
fixCheck the nightly documentation for the correct class name. Use `from flwr.client import Client` and adjust accordingly.
Upgrade
Version history
1.30.0.dev20260508latest on PyPI · released May 8, 2026
Audit
Dependencies
grpciorequiredgRPC communication between server and clients
protobufrequiredProtocol buffers for message serialization