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 Azure Cognitive Services package #4405

Closed
abhishekkumar123090 opened this issue Jun 21, 2018 · 8 comments
Closed

Unable to import Azure Cognitive Services package #4405

abhishekkumar123090 opened this issue Jun 21, 2018 · 8 comments

Comments

@abhishekkumar123090
Copy link

abhishekkumar123090 commented Jun 21, 2018

Hello all,

I am trying to use azure cognitive services. In the standard code, while importing the package, I am getting the following error:

Traceback (most recent call last):
File "azure-traning.py", line 1, in
from azure.cognitiveservices.vision.customvision.training import training_api
File "C:\Users\Asus\Desktop\nodejs\azure.py", line 1, in
from azure.cognitiveservices.vision.customvision.prediction import prediction_endpoint
ModuleNotFoundError: No module named 'azure.cognitiveservices'; 'azure' is not a package

I am not able to understand this. Please help.

I have done:

  1. pip install azure
  2. pip install azure-cognitiveservices-vision-customvision
@huguesv
Copy link
Contributor

huguesv commented Jun 21, 2018

You've named one of your project files azure.py, which conflicts with the name of a package you are trying to import. So it's trying to load things from your file rather than site-packages.

@abhishekkumar123090
Copy link
Author

Thank you for the above advise.
I have made the required changes in the file name and was getting the below error. So is it a problem of the api-key?

Traceback (most recent call last):
File "train_cm.py", line 12, in
project = trainer.create_project("PneumoniaNormal")
File "C:\Users\Asus\AppData\Local\Programs\Python\Python36\lib\site-packages\azure\cognitiveservices\vision\customvision\training\training_api.py", line 1537, in create_project
raise HttpOperationError(self._deserialize, response)
msrest.exceptions.HttpOperationError: Operation returned an invalid status code 'Access Denied'

@huguesv
Copy link
Contributor

huguesv commented Jun 21, 2018

It could be. Please check their tutorial if you haven't done so already, and if you need further help with their SDK, I've included the support page.

tutorial: https://docs.microsoft.com/en-us/azure/cognitive-services/Custom-Vision-Service/python-tutorial

support: https://github.com/Azure/azure-sdk-for-python/issues

@abhishekkumar123090
Copy link
Author

Thank you.

@kennethjmyers
Copy link

kennethjmyers commented Jul 2, 2018

I was also getting the same original issue (ModuleNotFoundError: No module named 'azure.cognitiveservices') for the spellcheck functions. Do NOT pip install azure . It installs all of the subpackages and I have a feeling there is an overlap between them that is causing issues.

I couldn't easily remove all the sub packages so I wiped my environment, started fresh, and this time only installed the pack I wanted (in this case pip install azure-cognitiveservices-language-spellcheck).

Now I am able to from azure.cognitiveservices.language.spellcheck import SpellCheckAPI without problem

@zooba
Copy link
Member

zooba commented Jul 3, 2018

If you suspect overlap, please report that on the azure-sdk-for-python repository so they can resolve it there.

But installing only the package you need is the right approach. Being able to install all of them at once is just for convenience.

@huguesv huguesv closed this as completed Nov 6, 2018
@javedulferdous
Copy link

Hello,
I'm having the same issue. How can I resolve this?
Thank you.

Traceback (most recent call last):
File "un.py", line 1, in
from azure.cognitiveservices.search.imagesearch import ImageSearchAPI
ImportError: cannot import name 'ImageSearchAPI' from 'azure.cognitiveservices.search.imagesearch' (C:\Users\jafra\OneDrive\Desktop\myvenv\lib\site-packages\azure\cognitiveservices\search\imagesearch_init_.py)

@ivandda
Copy link

ivandda commented Jan 8, 2025

You've named one of your project files azure.py, which conflicts with the name of a package you are trying to import. So it's trying to load things from your file rather than site-packages.

Thank you.

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

6 participants