Skip to main content

Source code: https://github.com/juju/python-libjuju

Bug reports: https://github.com/juju/python-libjuju/issues

Documentation: https://pythonlibjuju.readthedocs.io/en/latest/

Supported Python versions: 3.8 through 3.13 Supported Juju versions: 3.1 through 3.6

Design Notes

  • Asynchronous - Uses asyncio and async/await features of Python

  • Websocket-level bindings are programmatically generated (indirectly) from the Juju golang code, ensuring full api coverage

  • Provides an OO layer which encapsulates much of the websocket api and provides familiar nouns and verbs (e.g. Model.deploy(), Application.add_unit(), etc.)

Installation

pip3 install juju

Quickstart

Here’s a simple example that shows basic usage of the library. The example connects to the currently active Juju model, deploys a single unit of the ubuntu charm, then exits:

Note : Pylibjuju requires an already bootstrapped Juju controller to connect to.

#!/usr/bin/python3

import asyncio
import logging
import sys

from juju.model import Model


async def deploy():
    # Create a Model instance. We need to connect our Model to a Juju api
    # server before we can use it.
    model = Model()

    # Connect to the currently active Juju model
    await model.connect()

    try:
        # Deploy a single unit of the ubuntu charm, using the latest revision
        # from the stable channel of the Charm Store.
        ubuntu_app = await model.deploy(
          'ubuntu',
          application_name='my-ubuntu',
        )

        if '--wait' in sys.argv:
            # optionally block until the application is ready
            await model.wait_for_idle(status='active')

    finally:
        # Disconnect from the api server and cleanup.
        await model.disconnect()


def main():
    logging.basicConfig(level=logging.INFO)

    # If you want to see everything sent over the wire, set this to DEBUG.
    ws_logger = logging.getLogger('websockets.protocol')
    ws_logger.setLevel(logging.INFO)

    # Run the deploy coroutine in an asyncio event loop, using a helper
    # that abstracts loop creation and teardown.
    asyncio.run(deploy())


if __name__ == '__main__':
    main()

More examples can be found in the docs, as well as in the examples/ directory of the source tree which can be run using tox. For example, to run examples/connect_current_model.py, use:

tox -e example -- examples/connect_current_model.py

REPL

To experiment with the library in a REPL, launch python in asyncio mode

$ python3 -m asyncio

and then, to connect to the current model and fetch status:

>>> from juju.model import Model
>>> model = Model()
>>> await model.connect_current()
>>> status = await model.get_status()

Versioning

The current Pylibjuju release policy tracks the Juju release cadence. In particular, whenever Juju makes a latest/stable release, pylibjuju pushes out a release with the same version in the following week. Newly generated schemas will be updated per Juju releases.

Metadata

Release files for juju 3.6.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for juju 3.6.1.1
File Size Uploaded
juju-3.6.1.1.tar.gz 305.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for juju 3.6.1.1
File Interpreter ABI Platform
juju-3.6.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 592.2 kB

Release files / juju-3.6.1.1.tar.gz

Download URL juju-3.6.1.1.tar.gz
Size 305.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2289abd450515b7883f12f06d42f965d31939e711c496cb8713b4b058408e589
BLAKE2b-256 checksum
How to use checksums
66320816544d9997f66a48a5cd3e799d5f07687da1dc9b5234d44389cbd7b4fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.0

Release files / juju-3.6.1.1-py3-none-any.whl

Download URL juju-3.6.1.1-py3-none-any.whl
Size 287.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
19ede730130b03cd5a99850f812521c2eb93199771207b50e1edf86e5e47acb2
BLAKE2b-256 checksum
How to use checksums
9ea0b3e6e6b79409e384627a79636cd012dd03b5ae103669a868147faf9cd830
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.0

Release history Release notifications | RSS feed

3.6.1.2

1 release file

This release

3.6.1.1 This release

2 release files

3.5.2.1

1 release file

3.5.2.0

1 release file

3.5.0.0

1 release file

3.4.0.0

1 release file

3.3.1.1

1 release file

3.3.1.0

1 release file

3.3.0.0

1 release file

3.2.3.0

1 release file

3.2.2

1 release file

3.2.0.1

1 release file

3.1.0.1

1 release file

3.0.4

2 release files

3.0.3

2 release files

3.0.2

2 release files

3.0.1

1 release file

3.0.0

1 release file

2.9.11

2 release files

2.9.10

1 release file

2.9.9

1 release file

2.9.8

1 release file

2.9.7

1 release file

2.9.6

1 release file

2.9.5

1 release file

2.9.4

1 release file

2.9.3

1 release file

2.9.2

1 release file

2.9.1

1 release file

2.9.0

1 release file

2.8.6

1 release file

2.8.5

1 release file

2.8.4

1 release file

2.8.3

1 release file

2.8.2

1 release file

2.8.1

1 release file

2.8.0

1 release file

2.7.1

2 release files

2.7.0

1 release file

2.6.3

1 release file

2.6.2

1 release file

2.6.1

1 release file

2.6.0

1 release file

0.11.7

1 release file

0.11.6

1 release file

0.11.5

1 release file

0.11.4

1 release file

0.11.3

1 release file

0.11.2

1 release file

0.11.1

1 release file

0.11.0

1 release file

0.10.2

1 release file

0.10.1

1 release file

0.10.0

1 release file

0.9.1

1 release file

0.9.0

1 release file

0.8.0

1 release file

0.7.5

1 release file

0.7.4

1 release file

0.7.3

1 release file

0.7.2

1 release file

0.7.1

1 release file

0.7.0

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.3

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.3

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page