The get_facts module throws an AttributeError.
lwijnsma opened this issue · comments
Description of Issue/Question
When trying to use the get_facts
call the python module throws an AttributeError
.
Setup
(Router RB3011) <---> (Linux box with python and napalm)
napalm-ros version
napalm-ros==1.1.0
ROS version
[username@RouterOS] > /system package print
Columns: NAME, VERSION
# NAME VERSION
0 routeros 7.4
librouteros version
librouteros==3.2.1
python version
Python 3.8.10
Steps to Reproduce the Issue
napalm --user "username" --pasword "password" --vendor napalm_ros 10.10.0.1 call get_facts
Error Traceback
2022-08-17 15:02:25,119 - napalm - ERROR - method - Failed: 'Version' object has no attribute 'major'
================= Traceback =================
Traceback (most recent call last):
File "/opt/netbox-3.2.8/venv/bin/napalm", line 8, in <module>
sys.exit(main())
File "/opt/netbox-3.2.8/venv/lib/python3.8/site-packages/napalm/base/clitools/cl_napalm.py", line 308, in main
run_tests(args)
File "/opt/netbox-3.2.8/venv/lib/python3.8/site-packages/napalm/base/clitools/cl_napalm.py", line 291, in run_tests
call_getter(device, args.method, **method_kwargs)
File "/opt/netbox-3.2.8/venv/lib/python3.8/site-packages/napalm/base/clitools/cl_napalm.py", line 27, in wrapper
r = func(*args, **kwargs)
File "/opt/netbox-3.2.8/venv/lib/python3.8/site-packages/napalm/base/clitools/cl_napalm.py", line 255, in call_getter
r = func(**kwargs)
File "/opt/netbox-3.2.8/venv/lib/python3.8/site-packages/napalm_ros/ros.py", line 356, in get_facts
if pkg_resources.get_distribution("napalm").parsed_version.major == 3:
AttributeError: 'Version' object has no attribute 'major'
Which version of napalm
do you have ?
napalm==4.0.0
Which version of
napalm
do you have ?
Weird. Code works and it's tested on CI with python 3.8. Can you print out all attributes of Version
object ?
at https://github.com/napalm-automation-community/napalm-ros/blob/master/napalm_ros/ros.py#L345
print(dir(pkg_resources.get_distribution("napalm").parsed_version))
Weird. Code works and it's tested on CI with python 3.8. Can you print out all attributes of
Version
object ? at https://github.com/napalm-automation-community/napalm-ros/blob/master/napalm_ros/ros.py#L345print(dir(pkg_resources.get_distribution("napalm").parsed_version))
This is the output of that command:
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_compare', '_key', '_regex', '_version', 'base_version', 'is_postrelease', 'is_prerelease', 'local', 'public']
And this is the output of :
>>> print(pkg_resources.get_distribution("napalm").parsed_version)
4.0.0
parsed_version
should return Version object
e.g.
In [6]: ipy = pkg_resources.get_distribution('ipython')
In [7]: ipy
Out[7]: ipython 7.31.0 (/opt/homebrew/lib/python3.9/site-packages)
In [8]: ipy.version
Out[8]: '7.31.0'
In [9]: ipy.parsed_version
Out[9]: <Version('7.31.0')>
Try to upgrade setuptools
and pip
to newest versions.
Try to upgrade
setuptools
andpip
to newest versions.
pip was already on the latest version but upgrading setuptools from 44 to 65 did the trick.
thank you for the help