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

**URL:** <https://forums.balena.io/t/pygobject-nm-networkmanager-not-found-available-inside-container/355357>\
**Category:** Product support\
**Tags:** docker, network, docker-compose, dockerfile, raspberrypi4\
**Created:** [March 29, 2022, 8:50am UTC](https://forums.balena.io/t/pygobject-nm-networkmanager-not-found-available-inside-container/355357 "2022-03-29T08:50:41Z")\
**Posts on this page:** 1\
**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:** [March 29, 2022, 8:50am UTC](https://forums.balena.io/t/pygobject-nm-networkmanager-not-found-available-inside-container/355357/1 "2022-03-29T08:50:41Z")

</div>

I’m trying to get the device’s network info inside a container running on **balenaOS 2.94.4** ( **supervisor version 12.11.43** ) on a **Raspberry Pi 4** (4GB version, Rev1.2) 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:

2. **[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.1(heavily based on Ubuntu 20.04) it works without issues, leading me to believe there’s still some package or setting missing…

What am I missing or doing wrong?
