# REUPLOAD: PyGObject NM (NetworkManager?) not found/available inside container.

**URL:** <https://forums.balena.io/t/reupload-pygobject-nm-networkmanager-not-found-available-inside-container/365420>\
**Category:** balenaOS\
**Tags:** docker, network, docker-compose, dockerfile, raspberrypi4\
**Created:** [November 14, 2022, 1:49pm UTC](https://forums.balena.io/t/reupload-pygobject-nm-networkmanager-not-found-available-inside-container/365420 "2022-11-14T13:49:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![VromansN](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/vromansn/32/7790_2.png) [@VromansN](https://forums.balena.io/u/VromansN)\
**Post date:** [November 14, 2022, 1:49pm UTC](https://forums.balena.io/t/reupload-pygobject-nm-networkmanager-not-found-available-inside-container/365420/1 "2022-11-14T13:49:50Z")

</div>

**[ORIGINAL](https://forums.balena.io/t/pygobject-nm-networkmanager-not-found-available-inside-container/355357)**  
I’m trying to get the device’s network info inside a container running on **balenaOS 2.94.4** ( **supervisor version 14.3.3** ) on a **Raspberry Pi Compute Module 4** using **PyGObject** (using **Python 3.9.2** ). I’ve been using [these examples](https://github.com/NetworkManager/NetworkManager/tree/main/examples/python/gi), which are also mentioned in [this video](https://www.youtube.com/watch?v=e5-r_9ggHqI&t=4631s) (I followed along to satisfy other dependencies/prerequisites, listed below).

In order to get this working, there are a few things that need be done:

1. **[docker-compose.yml](https://github.com/balena-os/wifi-connect#balenaos-multicontainer-app)**:  
set `network-mode: "host"`  
add the following label: `io.balena.features.dbus: '1'`  
(optional?) add:

```auto
cap_add:
   - NET_ADMIN

```

the container already had `privileged: true`, so in this case the `cap_add` shouldn’t make a difference  
add following environment variable: `DBUS_SYSTEM_BUS_ADDRESS: "unix:path=/host/run/dbus/system_bus_socket"`

1. **[add dependencies](https://pygobject.readthedocs.io/en/latest/getting_started.html#ubuntu-logo-ubuntu-debian-logo-debian)**, I’ve tried both ways, but they both don’t seem to work properly (see later)  
2.1. install `network-manager` package in the desired container, this allows for the usage of the `nmcli` command, which does work for me and shows the correct info. The `network-manager` should also include [libnm](https://developer-old.gnome.org/libnm/stable/usage.html), although I’m not entirely sure of this. (In these docs the same implementation is used as in the examples linked above, as well as in the next section.)

In both cases (point 2), here’s what I get:

- `import gi`  
→ no problem
- `gi.require_version('NM', '1.0')` (I’m assuming NM stands for NetworkManager?)  
→ `ValueError: Namespace NM not available`
- `from gi.repository import NM`  
→ `ImportError: cannot import name NM, introspection typelib not found`

Off course I’ve tried searching for these errors online, but documentation/information seems extremely sparse.  
Running this inside docker on my local machine, or using `balena push` to push it to my device (local mode enabled for testing), these errors occur.  
When I run this in a virtual environment (using Python 3.9.10) on ZorinOS 16.2 (heavily based on Ubuntu 22.04) it works without issues, leading me to believe there’s still some package or setting missing…

What am I missing or doing wrong?

---

<div class="post-metadata">

**Author:** ![zack](https://avatars.discourse-cdn.com/v4/letter/z/f6c823/32.png) [@zack](https://forums.balena.io/u/zack)\
**Post date:** [August 10, 2023, 12:26am UTC](https://forums.balena.io/t/reupload-pygobject-nm-networkmanager-not-found-available-inside-container/365420/2 "2023-08-10T00:26:32Z")

</div>

Little late, but adding `gir1.2-nm-1.0` via apt worked for me.
