Azure Cognitive Service Environment Setup Error

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 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.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 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\ in <module>
4 print('Ready to use cognitive services at {} using key {}'.format(cog_endpoint, cog_key))
----> 6 from 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
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)

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.



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.