cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements
759
Views
0
Helpful
2
Replies
uncutgemsfan
Beginner

unable to install dnac_config module

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
bigevilbeard
Cisco Employee

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()
Pranav Mhatre
Beginner

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()
Create
Recognize Your Peers
Content for Community-Ad