0

I'm at loss how to integrate the python-nmcli module into my Python script. I seem to be fundamentally misunderstanding something about that module.

foo@bar:~ $ pip install python-nmcli
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: python-nmcli in ./.local/lib/python3.7/site-packages (0.1.1)

Installed.

>>> from nmcli import nm
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'nm' from 'nmcli' (/home/pi/.local/lib/python3.7/site-packages/nmcli/__init__.py)

That is the first one should do according to the module documentation. Bummer this already fails.

>>> import nmcli
>>> print(nmcli)
<module 'nmcli' from '/home/pi/.local/lib/python3.7/site-packages/nmcli/__init__.py'>

Ok, it's properly loaded at least.

>>> nmcli.dev.status()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'nmcli' has no attribute 'dev'

It does have a dev property but that one is not exposed.

>>> from nmcli import NMCommand
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'NMCommand' from 'nmcli' (/home/pi/.local/lib/python3.7/site-packages/nmcli/__init__.py)

Why can I not even import that class?

Marcel Stör
  • 22,695
  • 19
  • 92
  • 198

0 Answers0