Azure-sdk-for-python: ModuleNotFoundError: No module named 'azure.common'; 'azure' is not a package

Created on 11 Mar 2019  路  2Comments  路  Source: Azure/azure-sdk-for-python

Hello,

I am having an issue with using the azure-common package on my windows 10 system.
Python version:

Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

I run my python code from within pipenv to prevent packages from interfering with each other:

(.venv) C:\python\test>python -m pip install --upgrade pip
Looking in indexes: https://pypi.org/simple, https://pypi-read-only:****@enexis.jfrog.io/enexis/api/pypi/pypi/simple
Requirement already up-to-date: pip in c:\python\test\.venv\lib\site-packages (19.0.3)

(.venv) C:\python\test>exit

C:\python\test>python -m pip install --upgrade pip
Looking in indexes: https://pypi.org/simple, https://pypi-read-only:****@enexis.jfrog.io/enexis/api/pypi/pypi/simple
Requirement already up-to-date: pip in c:\applications\python37-32\lib\site-packages (19.0.3)

My Pipfile:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
ptpython = "*"
azure-common = "*"
azure-mgmt-resource = "*"
azure-mgmt-network = "*"
azure-nspkg = "*"

[requires]
python_version = "3.7"

Global installed packages:

C:\python\test\azure>pip freeze
certifi==2019.3.9
pipenv==2018.11.26
virtualenv==16.4.3
virtualenv-clone==0.5.1

code being ran:

from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.resource import ResourceManagementClient
from azure.mgmt.network import NetworkManagementClient

Error:

Traceback (most recent call last):
  File "azure.py", line 37, in <module>
    from azure.common.credentials import ServicePrincipalCredentials
  File "C:\python\test\azure.py", line 37, in <module>
    from azure.common.credentials import ServicePrincipalCredentials
ModuleNotFoundError: No module named 'azure.common'; 'azure' is not a package

Things I have tried:

  • delete .venv
  • create new folder for pipenv and install packages anew
  • upgrade pip using python -m pip install --upgrade pip then delete venv and install everything in pipenv again
  • I also uninstalled python 3.7, tested if pip or pipenv still worked - no it did not. Delete any folder still present. Re-install python 3.7 to a different folder. Upgrade pip. Install the pipenv package. Install the azure packages for the pipenv. And I additionally installed azure-nspkg as that was mentioned in one of the earlier threads here on GitHub, and it wasn't yet to be found in the Pipfile.lock after installing the other azure package - reference: https://github.com/Azure/azure-sdk-for-python/issues/1558

Anyone got any thoughts on fixing this?
I can comment the azure.common.credentials import line and it will give the exact same modulenotfound error on mgmt.resource, and same again for mgmt.network.

Mgmt

Most helpful comment

Please rename your personal file from azure.py to something else, as the message says, you file is understood by Python as THE azure name and hide everything else:

No module named 'azure.common'; 'azure' is not a package

All 2 comments

Please rename your personal file from azure.py to something else, as the message says, you file is understood by Python as THE azure name and hide everything else:

No module named 'azure.common'; 'azure' is not a package

I'm confident enough this is your issue to close it, but feel free to still comment if I'm wrong or open new issues if necessary. Thanks!

Was this page helpful?
0 / 5 - 0 ratings