Skip to content

Python 3.8 win32: DefaultAzureCredential and SharedTokenCacheCredential raise ImportError #8292

@chlowell

Description

@chlowell

Initializers of DefaultAzureCredential and SharedTokenCacheCredential raise ImportError when running Python 3.8 on Windows:

Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from azure.identity import DefaultAzureCredential
>>> DefaultAzureCredential()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\3.8\lib\site-packages\azure\identity\_credentials\default.py", line 39, in __init__
    SharedTokenCacheCredential(
  File "C:\3.8\lib\site-packages\azure\identity\_credentials\user.py", line 136, in __init__
    from msal_extensions.token_cache import WindowsTokenCache
  File "C:\3.8\lib\site-packages\msal_extensions\__init__.py", line 7, in <module>
    from .token_cache import WindowsTokenCache as TokenCache
  File "C:\3.8\lib\site-packages\msal_extensions\token_cache.py", line 8, in <module>
    from .cache_lock import CrossPlatLock
  File "C:\3.8\lib\site-packages\msal_extensions\cache_lock.py", line 5, in <module>
    import portalocker
  File "C:\3.8\lib\site-packages\portalocker\__init__.py", line 4, in <module>
    from . import portalocker
  File "C:\3.8\lib\site-packages\portalocker\portalocker.py", line 9, in <module>
    import win32file
ImportError: DLL load failed while importing win32file: The specified module could not be found.

No other credential is affected, so this can be worked around by substituting a specific component of DefaultAzureCredential such as ClientSecretCredential or EnvironmentCredential. SharedTokenCacheCredential, however, won't function on Python 3.8.

The cause of this is tracked at mhammond/pywin32#1431

Metadata

Metadata

Assignees

Labels

Azure.IdentityClientThis issue points to a problem in the data-plane of the library.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions