Skip to content

Napalm: cannot import name 'etree' from 'lxml' #652

@anthr76

Description

@anthr76

Current Behavior

I'm trying to using napalm but the dependencies within alpine appear to be broken? A releated issue to the problem is here babybuddy/babybuddy#336 (comment)

Expected Behavior

This bit to work, or it to work within netbox itself

bash-5.1$ source /opt/netbox/venv/bin/activate
(venv) bash-5.1$ python3.9
Python 3.9.5 (default, May 12 2021, 20:44:22)
[GCC 10.3.1 20210424] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from napalm import get_network_driver
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/netbox/venv/lib/python3.9/site-packages/napalm/__init__.py", line 11, in <module>
    import napalm.iosxr
  File "/opt/netbox/venv/lib/python3.9/site-packages/napalm/iosxr/__init__.py", line 22, in <module>
    from napalm.iosxr.iosxr import IOSXRDriver  # noqa
  File "/opt/netbox/venv/lib/python3.9/site-packages/napalm/iosxr/iosxr.py", line 23, in <module>
    from lxml import etree as ETREE
ImportError: cannot import name 'etree' from 'lxml' (/opt/netbox/venv/lib/python3.9/site-packages/lxml/__init__.py)
>>> import pprint

Docker Compose Version

N/A This is Kubernetes

Docker Version

Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.3", GitCommit:"c92036820499fedefec0f847e2054d824aea6cd1", GitTreeState:"clean", BuildDate:"2021-10-27T18:35:25Z", GoVersion:"go1.16.9", Compiler:"gc", Platform:"linux/amd64"}

The git Revision

?
skopeo inspect docker://docker.io/netboxcommunity/netbox:v3.0.10
{
    "Name": "docker.io/netboxcommunity/netbox",
    "Digest": "sha256:042371b7687b25d584408520cceb6eb1f153f41f14c95b73a3e9799055f4ffec"

The git Status

?

Startup Command

https://github.com/anthr76/infra/blob/main/gitops/base/infra/netbox/helm-release.yaml

NetBox Logs

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/netbox/venv/lib/python3.9/site-packages/napalm/__init__.py", line 11, in <module>
    import napalm.iosxr
  File "/opt/netbox/venv/lib/python3.9/site-packages/napalm/iosxr/__init__.py", line 22, in <module>
    from napalm.iosxr.iosxr import IOSXRDriver  # noqa
  File "/opt/netbox/venv/lib/python3.9/site-packages/napalm/iosxr/iosxr.py", line 23, in <module>
    from lxml import etree as ETREE
ImportError: cannot import name 'etree' from 'lxml' (/opt/netbox/venv/lib/python3.9/site-packages/lxml/__init__.py)
>>> import pprint


### Content of docker-compose.override.yml

```yaml
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions