Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Py3 breakage? #37

Open
FlorianHeigl opened this issue Feb 9, 2021 · 7 comments
Open

Py3 breakage? #37

FlorianHeigl opened this issue Feb 9, 2021 · 7 comments

Comments

@FlorianHeigl
Copy link

I'm just a beginner learning the modules i'll need in the next months, but this seems to be a real issue. I would strongly suggest there's some issue in python compatibilty. I'm running netbox-docker by the way, and added this driver via pip3 install napalm-aos.

bash-5.1$ python3
Python 3.8.7 (default, Dec 26 2020, 08:45:55) 
[GCC 10.2.1 20201203] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> from napalm import get_network_driver
dr>>> driver = get_network_driver("procurve")
>>> driver = get_network_driver("onyx")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.8/site-packages/napalm/base/__init__.py", line 97, in get_network_driver
    raise ModuleImportError(
napalm.base.exceptions.ModuleImportError: Cannot import "onyx". Is the library installed?
>>> driver = get_network_driver("aos")
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/napalm_aos/utils/AlcatelOS.py", line 7, in <module>
    from napalm.base.utils import py23_compat
ImportError: cannot import name 'py23_compat' from 'napalm.base.utils' (/usr/lib/python3.8/site-packages/napalm/base/utils/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/napalm_aos/aos.py", line 27, in <module>
    from napalm_aos.utils.AlcatelOS import *
  File "/usr/lib/python3.8/site-packages/napalm_aos/utils/AlcatelOS.py", line 13, in <module>
    from napalm_base.utils import py23_compat
ModuleNotFoundError: No module named 'napalm_base'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.8/site-packages/napalm/base/__init__.py", line 95, in get_network_driver
    raise e
  File "/usr/lib/python3.8/site-packages/napalm/base/__init__.py", line 86, in get_network_driver
    module = importlib.import_module(module_name)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/lib/python3.8/site-packages/napalm_aos/__init__.py", line 17, in <module>
    from napalm_aos.aos import AOSDriver
  File "/usr/lib/python3.8/site-packages/napalm_aos/aos.py", line 39, in <module>
    import napalm_base.constants as C
ModuleNotFoundError: No module named 'napalm_base'

the procurve driver just loaded a moment before!

@jefvantongerloo
Copy link

AOSDriver is not compatible with build-in Napalm 3.0 yet, you have to use Napalm version 3.2.1
This PR could fix the problem: #30

@FlorianHeigl
Copy link
Author

@jefvantongerloo so nice of you to take time for a reply.
I am a bit confused - isn't 3.2.1 newer than 3.0?

@jefvantongerloo
Copy link

Sorry typo, the compatible version is 2.3.1.
When I use and test Napalm 3.0 I get the same error message.

@FlorianHeigl
Copy link
Author

Thanks! Hopefully that PR will move forward some day.

@napalmaos
Copy link
Collaborator

Please help to test again with latest code

@FlorianHeigl
Copy link
Author

It seems to do a lot better now:

floh@blackbox:~/git/netbox-docker$ docker exec -ti netbox-docker_netbox_1 bash
bash-5.1$ python3
Python 3.8.7 (default, Feb 19 2021, 01:11:05) 
[GCC 10.2.1 20201203] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> from napalm import get_network_driver

I need to replicate things in an env with AOS switches for actual testing, but it seems you solved the main py3 pain points already!

@jefvantongerloo
Copy link

@FlorianHeigl Tested through netbox-docker and confirmed working with Python3 and Netbox:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants