SOLVED

Azure Cognitive Service Environment Setup Error

%3CLINGO-SUB%20id%3D%22lingo-sub-2391784%22%20slang%3D%22en-US%22%3EAzure%20Cognitive%20Service%20Environment%20Setup%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2391784%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20using%20Visual%20Studio%20Code%20for%20learning%2C%20experiencing%20and%20experimenting%20the%20Azure%20AI%20services.%20I%20am%20using%20git%20learning%20Module%20%3CSTRONG%3EMSLEARN-AI-900.%26nbsp%3B%3C%2FSTRONG%3EIn%20the%20file%20%2201-Image%20Analysis%20with%20Computer%20Vision.ipynb%22%2C%20while%20running%20the%20following%20code%3A%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3Efrom%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bazure.cognitiveservices.vision.computervision%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eimport%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3BComputerVisionClient%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Efrom%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bmsrest.authentication%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eimport%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3BCognitiveServicesCredentials%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Efrom%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bpython_code%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eimport%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bvision%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Eimport%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bos%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%25%3C%2FSPAN%3E%3CSPAN%3Ematplotlib%26nbsp%3Binline%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23%26nbsp%3BGet%26nbsp%3Bthe%26nbsp%3Bpath%26nbsp%3Bto%26nbsp%3Ban%26nbsp%3Bimage%26nbsp%3Bfile%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Eimage_path%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bos.path.join(%3C%2FSPAN%3E%3CSPAN%3E'data'%3C%2FSPAN%3E%3CSPAN%3E%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E'vision'%3C%2FSPAN%3E%3CSPAN%3E%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E'store_cam1.jpg'%3C%2FSPAN%3E%3CSPAN%3E)%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23%26nbsp%3BGet%26nbsp%3Ba%26nbsp%3Bclient%26nbsp%3Bfor%26nbsp%3Bthe%26nbsp%3Bcomputer%26nbsp%3Bvision%26nbsp%3Bservice%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Ecomputervision_client%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3BComputerVisionClient(cog_endpoint%2C%26nbsp%3BCognitiveServicesCredentials(cog_key))%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23%26nbsp%3BGet%26nbsp%3Ba%26nbsp%3Bdescription%26nbsp%3Bfrom%26nbsp%3Bthe%26nbsp%3Bcomputer%26nbsp%3Bvision%26nbsp%3Bservice%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Eimage_stream%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eopen%3C%2FSPAN%3E%3CSPAN%3E(image_path%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22rb%22%3C%2FSPAN%3E%3CSPAN%3E)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Edescription%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bcomputervision_client.describe_image_in_stream(image_stream)%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23%26nbsp%3BDisplay%26nbsp%3Bimage%26nbsp%3Band%26nbsp%3Bcaption%26nbsp%3B(code%26nbsp%3Bin%26nbsp%3Bhelper_scripts%2Fvision.py)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Evision.show_image_caption(image_path%2C%26nbsp%3Bdescription)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EI%20am%20getting%20the%20following%20%3CSTRONG%3EERROR%3C%2FSTRONG%3E%3A%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%3CSTRONG%3EModuleNotFoundError%3C%2FSTRONG%3E%20Traceback%20(most%20recent%20call%20last)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%3CSTRONG%3E%3CIPYTHON-INPUT-3-72A4E0DFFF5E%3E%3C%2FIPYTHON-INPUT-3-72A4E0DFFF5E%3E%3C%2FSTRONG%3E%20in%20%3CMODULE%3E%20%3C%2FMODULE%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%3CSTRONG%3E----%26gt%3B%201%20from%3C%2FSTRONG%3E%20azure%3CSTRONG%3E.%3C%2FSTRONG%3Ecognitiveservices%3CSTRONG%3E.%3C%2FSTRONG%3Evision%3CSTRONG%3E.%3C%2FSTRONG%3Ecomputervision%20%3CSTRONG%3Eimport%3C%2FSTRONG%3E%20ComputerVisionClient%20%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E2%20%3CSTRONG%3Efrom%3C%2FSTRONG%3E%20msrest%3CSTRONG%3E.%3C%2FSTRONG%3Eauthentication%20%3CSTRONG%3Eimport%3C%2FSTRONG%3E%20CognitiveServicesCredentials%20%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E3%20%3CSTRONG%3Efrom%3C%2FSTRONG%3E%20python_code%20%3CSTRONG%3Eimport%3C%2FSTRONG%3E%20vision%20%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E4%20%3CSTRONG%3Eimport%3C%2FSTRONG%3E%20os%20%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E5%20get_ipython%3CSTRONG%3E(%3C%2FSTRONG%3E%3CSTRONG%3E)%3C%2FSTRONG%3E%3CSTRONG%3E.%3C%2FSTRONG%3Erun_line_magic%3CSTRONG%3E(%3C%2FSTRONG%3E%3CSTRONG%3E'matplotlib'%3C%2FSTRONG%3E%3CSTRONG%3E%2C%3C%2FSTRONG%3E%20%3CSTRONG%3E'inline'%3C%2FSTRONG%3E%3CSTRONG%3E)%3C%2FSTRONG%3E%20%3CSTRONG%3EG%3A%5CUsers%5CHimanshu%5CAppData%5CLocal%5CPrograms%5CPython%5CPython36-32%5Cazure.py%3C%2FSTRONG%3E%20in%20%3CMODULE%3E%20%3C%2FMODULE%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E4%20print%3CSTRONG%3E(%3C%2FSTRONG%3E%3CSTRONG%3E'Ready%20to%20use%20cognitive%20services%20at%20%7B%7D%20using%20key%20%7B%7D'%3C%2FSTRONG%3E%3CSTRONG%3E.%3C%2FSTRONG%3Eformat%3CSTRONG%3E(%3C%2FSTRONG%3Ecog_endpoint%3CSTRONG%3E%2C%3C%2FSTRONG%3E%20cog_key%3CSTRONG%3E)%3C%2FSTRONG%3E%3CSTRONG%3E)%3C%2FSTRONG%3E%20%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E5%20%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%3CSTRONG%3E----%26gt%3B%206%20from%3C%2FSTRONG%3E%20azure%3CSTRONG%3E.%3C%2FSTRONG%3Ecognitiveservices%3CSTRONG%3E.%3C%2FSTRONG%3Evision%3CSTRONG%3E.%3C%2FSTRONG%3Ecomputervision%20%3CSTRONG%3Eimport%3C%2FSTRONG%3E%20ComputerVisionClient%20%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E7%20%3CSTRONG%3Efrom%3C%2FSTRONG%3E%20msrest%3CSTRONG%3E.%3C%2FSTRONG%3Eauthentication%20%3CSTRONG%3Eimport%3C%2FSTRONG%3E%20CognitiveServicesCredentials%20%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E8%20%3CSTRONG%3Efrom%3C%2FSTRONG%3E%20python_code%20%3CSTRONG%3Eimport%3C%2FSTRONG%3E%20vision%20%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%3CSTRONG%3EModuleNotFoundError%3C%2FSTRONG%3E%3A%20No%20module%20named%20'azure.cognitiveservices'%3B%20'azure'%20is%20not%20a%20package%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3ETo%20check%20the%20proper%20installation%20of%20azure%20module%2C%20run%20the%20pip3%20list%20command%20on%20cmd%2C%20results%20are%20as%20follows%3A%3C%2FDIV%3E%3CDIV%3EPS%20C%3A%5CUsers%5CHimanshu%5Cmslearn-ai900%26gt%3B%20pip3%20list%3CBR%20%2F%3EPackage%20Version%3CBR%20%2F%3E---------------------------------------------%20------------%3CBR%20%2F%3E-ip%2020.0.2%3CBR%20%2F%3Easn1crypto%200.24.0%3CBR%20%2F%3Eazure-ai-formrecognizer%203.0.0%3CBR%20%2F%3Eazure-cognitiveservices-vision-computervision%200.9.0%3CBR%20%2F%3Eazure-cognitiveservices-vision-customvision%203.1.0%3CBR%20%2F%3Eazure-common%201.1.27%3CBR%20%2F%3Eazure-core%201.14.0%3CBR%20%2F%3Ebackcall%200.2.0%3CBR%20%2F%3Ebeautifulsoup4%204.9.0%3CBR%20%2F%3Ecertifi%202020.4.5.1%3CBR%20%2F%3Ecffi%201.11.5%3CBR%20%2F%3Echardet%203.0.4%3CBR%20%2F%3Eclick%207.1.1%3CBR%20%2F%3Ecolorama%200.4.4%3CBR%20%2F%3Ecryptography%202.3.1%3CBR%20%2F%3Edecorator%205.0.9%3CBR%20%2F%3Edjango%202.1%3CBR%20%2F%3Egoogle%202.0.3%3CBR%20%2F%3EgTTS%202.1.1%3CBR%20%2F%3EgTTS-token%201.1.3%3CBR%20%2F%3Eh5py%202.10.0%3CBR%20%2F%3Eidna%202.9%3CBR%20%2F%3Eimportlib-metadata%201.6.0%3CBR%20%2F%3Eimutils%200.5.3%3CBR%20%2F%3Einflect%204.1.0%3CBR%20%2F%3Eipykernel%205.5.5%3CBR%20%2F%3Eipython%207.16.1%3CBR%20%2F%3Eipython-genutils%200.2.0%3CBR%20%2F%3Eisodate%200.6.0%3CBR%20%2F%3Ejaraco.itertools%205.0.0%3CBR%20%2F%3Ejedi%200.18.0%3CBR%20%2F%3Ejoblib%200.14.1%3CBR%20%2F%3Ejupyter-client%206.1.12%3CBR%20%2F%3Ejupyter-core%204.7.1%3CBR%20%2F%3EKeras%202.3.1%3CBR%20%2F%3EKeras-Applications%201.0.8%3CBR%20%2F%3EKeras-Preprocessing%201.1.0%3CBR%20%2F%3Elxml%204.5.1%3CBR%20%2F%3Emore-itertools%208.2.0%3CBR%20%2F%3Emsrest%200.6.21%3CBR%20%2F%3Enumpy%201.18.3%3CBR%20%2F%3Eoauthlib%203.1.0%3CBR%20%2F%3Eopencv-contrib-python%204.2.0.34%3CBR%20%2F%3Epandas%200.24.1%3CBR%20%2F%3Eparso%200.8.2%3CBR%20%2F%3Epickleshare%200.7.5%3CBR%20%2F%3EPillow%207.1.2%3CBR%20%2F%3Epip%2020.1%3CBR%20%2F%3Eplaysound%201.2.2%3CBR%20%2F%3Eprompt-toolkit%203.0.18%3CBR%20%2F%3EPyAudio%200.2.11%3CBR%20%2F%3Epycparser%202.18%3CBR%20%2F%3EPygments%202.9.0%3CBR%20%2F%3EPyMySQL%200.9.2%3CBR%20%2F%3Epyspeech%200.0.0%3CBR%20%2F%3Epython-dateutil%202.8.0%3CBR%20%2F%3Epytz%202018.5%3CBR%20%2F%3Epywin32%20300%3CBR%20%2F%3EPyYAML%205.3.1%3CBR%20%2F%3Epyzmq%2022.0.3%3CBR%20%2F%3Erequests%202.23.0%3CBR%20%2F%3Erequests-oauthlib%201.3.0%3CBR%20%2F%3Escikit-learn%200.22.2.post1%3CBR%20%2F%3Escipy%201.4.1%3CBR%20%2F%3Eselenium%203.141.0%3CBR%20%2F%3Esetuptools%2028.8.0%3CBR%20%2F%3Esix%201.14.0%3CBR%20%2F%3Esoupsieve%202.0%3CBR%20%2F%3ESpeechRecognition%203.8.1%3CBR%20%2F%3Etornado%206.1%3CBR%20%2F%3Etraitlets%204.3.3%3CBR%20%2F%3Eurllib3%201.25.8%3CBR%20%2F%3Ewcwidth%200.2.5%3CBR%20%2F%3Ewheel%200.36.2%3CBR%20%2F%3Ewolframalpha%204.0.0%3CBR%20%2F%3Exmltodict%200.12.0%3CBR%20%2F%3Ezipp%203.1.0%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2394453%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20Cognitive%20Service%20Environment%20Setup%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2394453%22%20slang%3D%22en-US%22%3E%3CP%3E%3CU%3E%3CSTRONG%3EError%20Resolved%3A%3C%2FSTRONG%3E%3C%2FU%3E%20But%20exact%20and%20authentic%20reason%20of%20error%20is%20still%20unknown.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CU%3E%3CSTRONG%3ESteps%20taken%20to%20Resolve%20Error%3A%26nbsp%3B%3C%2FSTRONG%3E%3C%2FU%3E%3C%2FP%3E%3CP%3E1.%20Uninstalled%20Python%2C%20Python%203.6%20and%20Python%203.5%20were%20installed%20on%20my%20system.%20I%20uninstalled%20both.%3C%2FP%3E%3CP%3E2.%20Installed%20newer%20version%20of%20python%20i.e.%20Python%203.8.%20I%20installed%20it%20after%20clearing%20all%20temporary%20files%20and%20folders%2C%20in%20totally%20new%20drive%20and%20folder.%3C%2FP%3E%3CP%3E3.%20Installed%20the%20required%20Azure%20python%20modules%20as%20per%20the%20instruction%20guide%20in%20the%20AI-900%20learning%20path.%3C%2FP%3E%3CP%3EAfter%20re-installing%20Python%2C%20everything%20started%20working%2C%20I%20did%20%3CSTRONG%3Enot%3C%2FSTRONG%3E%20uninstalled%20Visual%20Studio%20Code.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CU%3E%3CSTRONG%3EConclusion%3A%3C%2FSTRONG%3E%3C%2FU%3E%3C%2FP%3E%3CP%3EThe%20exact%20and%20authentic%20reasons%20of%20error%20is%20still%20unknown%2C%20but%20there%20are%20following%20inference%20can%20be%20considered%3A%3C%2FP%3E%3CP%3E1.%20Installing%20TWO%20python%20versions%20on%20the%20system%20may%20lead%20to%20this%20error%2C%20so%20try%20to%20install%20and%20use%20only%20one%20python%20version%20at%20a%20time.%26nbsp%3B%3C%2FP%3E%3CP%3E2.%20While%20learning%20this%20code%20in%20VS%20Code%2C%20I%20also%20copied%20that%20same%20code%2C%20imports%20azure%20packages%20and%20executed%20them%20in%20python%20shell.%20So%20there%20were%20two%20programs%20that%20were%20trying%20to%20call%20azure%20packages%20from%20two%20different%20python%20consoles.%20Again%20this%20ambiguity%20may%20result%20in%20that%20error.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I am using Visual Studio Code for learning, experiencing and experimenting the Azure AI services. I am using git learning Module MSLEARN-AI-900. In the file "01-Image Analysis with Computer Vision.ipynb", while running the following code:

from azure.cognitiveservices.vision.computervision import ComputerVisionClient
from msrest.authentication import CognitiveServicesCredentials
from python_code import vision
import os
%matplotlib inline

# Get the path to an image file
image_path = os.path.join('data''vision''store_cam1.jpg')

# Get a client for the computer vision service
computervision_client = ComputerVisionClient(cog_endpoint, CognitiveServicesCredentials(cog_key))

# Get a description from the computer vision service
image_stream = open(image_path, "rb")
description = computervision_client.describe_image_in_stream(image_stream)

# Display image and caption (code in helper_scripts/vision.py)
vision.show_image_caption(image_path, description)
 
I am getting the following ERROR:
 
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-3-72a4e0dfff5e> in <module>
----> 1 from azure.cognitiveservices.vision.computervision import ComputerVisionClient
2 from msrest.authentication import CognitiveServicesCredentials
3 from python_code import vision
4 import os
5 get_ipython().run_line_magic('matplotlib', 'inline') G:\Users\Himanshu\AppData\Local\Programs\Python\Python36-32\azure.py in <module>
4 print('Ready to use cognitive services at {} using key {}'.format(cog_endpoint, cog_key))
5
----> 6 from azure.cognitiveservices.vision.computervision import ComputerVisionClient
7 from msrest.authentication import CognitiveServicesCredentials
8 from python_code import vision
ModuleNotFoundError: No module named 'azure.cognitiveservices'; 'azure' is not a package
 
To check the proper installation of azure module, run the pip3 list command on cmd, results are as follows:
PS C:\Users\Himanshu\mslearn-ai900> pip3 list
Package Version
--------------------------------------------- ------------
-ip 20.0.2
asn1crypto 0.24.0
azure-ai-formrecognizer 3.0.0
azure-cognitiveservices-vision-computervision 0.9.0
azure-cognitiveservices-vision-customvision 3.1.0
azure-common 1.1.27
azure-core 1.14.0
backcall 0.2.0
beautifulsoup4 4.9.0
certifi 2020.4.5.1
cffi 1.11.5
chardet 3.0.4
click 7.1.1
colorama 0.4.4
cryptography 2.3.1
decorator 5.0.9
django 2.1
google 2.0.3
gTTS 2.1.1
gTTS-token 1.1.3
h5py 2.10.0
idna 2.9
importlib-metadata 1.6.0
imutils 0.5.3
inflect 4.1.0
ipykernel 5.5.5
ipython 7.16.1
ipython-genutils 0.2.0
isodate 0.6.0
jaraco.itertools 5.0.0
jedi 0.18.0
joblib 0.14.1
jupyter-client 6.1.12
jupyter-core 4.7.1
Keras 2.3.1
Keras-Applications 1.0.8
Keras-Preprocessing 1.1.0
lxml 4.5.1
more-itertools 8.2.0
msrest 0.6.21
numpy 1.18.3
oauthlib 3.1.0
opencv-contrib-python 4.2.0.34
pandas 0.24.1
parso 0.8.2
pickleshare 0.7.5
Pillow 7.1.2
pip 20.1
playsound 1.2.2
prompt-toolkit 3.0.18
PyAudio 0.2.11
pycparser 2.18
Pygments 2.9.0
PyMySQL 0.9.2
pyspeech 0.0.0
python-dateutil 2.8.0
pytz 2018.5
pywin32 300
PyYAML 5.3.1
pyzmq 22.0.3
requests 2.23.0
requests-oauthlib 1.3.0
scikit-learn 0.22.2.post1
scipy 1.4.1
selenium 3.141.0
setuptools 28.8.0
six 1.14.0
soupsieve 2.0
SpeechRecognition 3.8.1
tornado 6.1
traitlets 4.3.3
urllib3 1.25.8
wcwidth 0.2.5
wheel 0.36.2
wolframalpha 4.0.0
xmltodict 0.12.0
zipp 3.1.0
1 Reply
best response confirmed by HimanshuMathur (New Contributor)
Solution

Error Resolved: But exact and authentic reason of error is still unknown.

 

Steps taken to Resolve Error: 

1. Uninstalled Python, Python 3.6 and Python 3.5 were installed on my system. I uninstalled both.

2. Installed newer version of python i.e. Python 3.8. I installed it after clearing all temporary files and folders, in totally new drive and folder.

3. Installed the required Azure python modules as per the instruction guide in the AI-900 learning path.

After re-installing Python, everything started working, I did not uninstalled Visual Studio Code.

 

Conclusion:

The exact and authentic reasons of error is still unknown, but there are following inference can be considered:

1. Installing TWO python versions on the system may lead to this error, so try to install and use only one python version at a time. 

2. While learning this code in VS Code, I also copied that same code, imports azure packages and executed them in python shell. So there were two programs that were trying to call azure packages from two different python consoles. Again this ambiguity may result in that error.

 

Thanks