mpenning / ciscoconfparse

Parse, Audit, Query, Build, and Modify Arista / Cisco / Juniper / Palo Alto / F5 configurations.
http://www.pennington.net/py/ciscoconfparse/
GNU General Public License v3.0
799 stars 220 forks source link

[Bug]: ModuleNotFoundError: No module named 'yaml' when hier_config==3.0.0 #304

Open jpkrajewski opened 5 days ago

jpkrajewski commented 5 days ago

Contact Details

jakubpkrajewski@gmail.com

What happened?

The package hier-config==3.0.0 does not include the yaml module as part of its dependencies. Therefore, the responsibility for installing PyYAML (the package providing the yaml module) lies with ciscoconfparse, which should declare it as a dependency and ensure it gets installed automatically.

from ciscoconfparse import CiscoConfParse
Traceback (most recent call last):
  File "/home/jakub/private/test/main.py", line 1, in <module>
    from ciscoconfparse import CiscoConfParse
  File "/home/jakub/private/test/.venv/lib/python3.11/site-packages/ciscoconfparse/__init__.py", line 30, in <module>
    from ciscoconfparse.ciscoconfparse import *
  File "/home/jakub/private/test/.venv/lib/python3.11/site-packages/ciscoconfparse/ciscoconfparse.py", line 48, in <module>
    import yaml
ModuleNotFoundError: No module named 'yaml'

CiscoConfParse Version

1.9.51

What Operating System are you using?

Linux - Debian, Ubuntu, CentOS, RHEL or others

What Python version(s) have this problem?

Python 3.10, Other (please specify)

Show us how to reproduce the problem. Please tell us if the problem is specific to certain inputs or situations.

pip install ciscoconfparse

Python tracebacks

Traceback (most recent call last):
  File "/home/jakub/private/test/main.py", line 1, in <module>
    from ciscoconfparse import CiscoConfParse
  File "/home/jakub/private/test/.venv/lib/python3.11/site-packages/ciscoconfparse/__init__.py", line 30, in <module>
    from ciscoconfparse.ciscoconfparse import *
  File "/home/jakub/private/test/.venv/lib/python3.11/site-packages/ciscoconfparse/ciscoconfparse.py", line 48, in <module>
    import yaml
ModuleNotFoundError: No module named 'yaml'

Relevant log output

Package           Version
----------------- -------
annotated-types   0.7.0
ciscoconfparse    1.9.51
Deprecated        1.2.15
dnspython         2.7.0
hier-config       3.0.0
loguru            0.7.2
passlib           1.7.4
pip               24.0
pydantic          2.10.0
pydantic_core     2.27.0
setuptools        65.5.0
toml              0.10.2
typing_extensions 4.12.2
wrapt             1.16.0

Code of Conduct

mpenning commented 5 days ago

This happened because I mistakenly assumed that hier_config==2.2.3 would keep using PyYAML, but they didn't starting in version 3.0.0.

Fix:

Workaround for ciscoconfparse < 1.9.52:

If your package depends on ciscoconfparse < 1.9.52, you'll have to manually declare PyYAML or hier_config==2.2.3 in your dependencies.

NOTE ciscoconfparse is end of life; it will get no more releases.