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

Unable to import Sequence from collections #380

Open
MrFanciful opened this issue May 29, 2022 · 1 comment
Open

Unable to import Sequence from collections #380

MrFanciful opened this issue May 29, 2022 · 1 comment

Comments

@MrFanciful
Copy link

Hi

Studying for the DevNet exam and the code below produces the error at the bottom.

import sys
import acitoolkit.acitoolkit as aci

APIC_URL = 'https://10.10.20.14'
USERNAME = 'admin'
PASSWORD = 'C1sco12345'

SESSION = aci.Session(APIC_URL, USERNAME, PASSWORD, verify_ssl=False)
RESP = SESSION.login()
if not RESP.ok:
    print('Could not log into APIC.')
    sys.exit()

END_POINTS = aci.Endpoint.get(SESSION)
print(f'{"MAC ADDRESS":19s}{"IP ADDRESS":14s}{"ENCAP":10s}{"TENANT":8s}{"APP PROFILE":17s}{"EPG":10s}')
print('-' * 80)

for EP in END_POINTS:
    epg = EP.get_parent()
    app_profile = epg.get_parent()
    tenant = app_profile.get_parent()
    print(f'{EP.mac:19s}{EP.ip:14s}{EP.encap:10s}{tenant.name:8s}{app_profile.name:17s}{epg.name:10s}')

Error:

Traceback (most recent call last):
File "/Users/davidlawson/Documents/PycharmProjects/cisco_devnet/aci_get_endpoints.py", line 3, in
import acitoolkit.acitoolkit as aci
File "/Users/davidlawson/Documents/PycharmProjects/cisco_devnet/venv/lib/python3.10/site-packages/acitoolkit/init.py", line 35, in
from .acitoolkit import ( # noqa
File "/Users/davidlawson/Documents/PycharmProjects/cisco_devnet/venv/lib/python3.10/site-packages/acitoolkit/acitoolkit.py", line 33, in
from collections import Sequence
ImportError: cannot import name 'Sequence' from 'collections' (/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/collections/init.py)

I'm running Python 3.10.4 with acitoolkit 0.4

@mpsOxygen
Copy link

Because you are using python 3.10 you need to change this line: from collections import Sequence
into this line: from collections.abc import Sequence

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

2 participants