cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1091
Views
0
Helpful
2
Replies

unable to install dnac_config module

uncutgemsfan
Level 1
Level 1

I wasnt able to download directly from github but I am doing this lab...

 

https://developer.cisco.com/learning/tracks/dnacenter-programmability/dnac-rest-apis/dnac-101-auth/step/2

 

can do this with postman but having issues with python

 

I had to copy and paste the script into sublime text and save as python file.

I made a new folder on my desktop and added the path to system path

 

when I try to do from dnac import ....

 

I get this ...

 

>>> from dnac_config import DNAC
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'dnac_config'

 

any info is appreciated

2 Replies 2

Thanks for noting this, i see a mistake in the learning lab - i have opened this support request with the team to look at this https://github.com/CiscoDevNet/learning-labs-issues/issues/278

 

Please use the following

 

import requests
from requests.auth import HTTPBasicAuth
from dnac_config import DNAC_IP, USERNAME, PASSWORD

requests.packages.urllib3.disable_warnings()

def get_auth_token():
    url = 'https://sandboxdnac.cisco.com/dna/system/api/v1/auth/token'
    resp = requests.post(url, auth=HTTPBasicAuth(USERNAME, PASSWORD), verify=False)
    token = resp.json()['Token']
    print("Token Retrieved: {}".format(token))
    return token

if __name__ == "__main__":
 get_auth_token()
Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

Pranav Mhatre
Level 1
Level 1

SyntaxError: invalid syntax
PS C:\Users\cbqz9250> & python c:/Users/cbqz9250/CloudDrive/Documents/Python/Code/testtoken.py
Traceback (most recent call last):
File "c:\Users\cbqz9250\CloudDrive\Documents\Python\Code\testtoken.py", line 3, in <module>
from dnac_config import DNAC_IP, USERNAME, PASSWORD
ModuleNotFoundError: No module named 'dnac_config'
PS C:\Users\cbqz9250>

 

Still getting same error -->

Code -->

 

import requests
from requests.auth import HTTPBasicAuth
from dnac_config import DNAC_IP, USERNAME, PASSWORD

requests.packages.urllib3.disable_warnings()

def get_auth_token():
    resp = requests.post(url, auth=HTTPBasicAuth(USERNAME, PASSWORD), verify=False)
    token = resp.json()['Token']
    print("Token Retrieved: {}".format(token))
    return token

if __name__ == "__main__":
 get_auth_token()
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: