Skip to content

After upgrade to 2.77 az errors - DLL load failed while importing win32file: specified module could not be found #32151

Closed

Description

@eliassal

Describe the bug

I upgraded my az cli yesterday to 2.77, since ever, ahtever command I run I get

Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/main.py", line 13, in
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/telemetry.py", line 19, in
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/telemetry/init.py", line 9, in
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\portalocker/init.py", line 4, in
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\portalocker/portalocker.py", line 11, in
ImportError: DLL load failed while importing win32file: The specified module could not be found.

whereas earlier version I think it was 2.55 was working without any issues

Related command

az account show
or even az upgrade
or az

Errors

Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/main.py", line 13, in
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/telemetry.py", line 19, in
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/telemetry/init.py", line 9, in
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\portalocker/init.py", line 4, in
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\portalocker/portalocker.py", line 11, in
ImportError: DLL load failed while importing win32file: The specified module could not be found.

Issue script & Debug output

az account show --debug
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/main.py", line 13, in
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/telemetry.py", line 19, in
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/telemetry/init.py", line 9, in
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\portalocker/init.py", line 4, in
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\portalocker/portalocker.py", line 11, in
ImportError: DLL load failed while importing win32file: The specified module could not be found.

Expected behavior

AZ cli works as before

Environment Summary

az --version
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/main.py", line 13, in
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/telemetry.py", line 19, in
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/telemetry/init.py", line 9, in
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\portalocker/init.py", line 4, in
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\portalocker/portalocker.py", line 11, in
ImportError: DLL load failed while importing win32file: The specified module could not be found.

Additional context

No response

Activity

  1. added
    bugThis issue requires a change to an existing behavior in the product in order to be resolved.
    on Sep 21, 2025
  2. yonzhan commented on Sep 21, 2025

    @yonzhan
    Collaborator

    Thank you for opening this issue, we will look into it.

  3. added
    customer-reportedIssues that are reported by GitHub users external to the Azure organization.
    ARMaz resource/group/lock/tag/deployment/policy/managementapp/account management-group
    on Sep 21, 2025
  4. added
    Azure CLI TeamThe command of the issue is owned by Azure CLI team
    questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
    on Sep 21, 2025
  5. removed
    bugThis issue requires a change to an existing behavior in the product in order to be resolved.
    on Sep 21, 2025
  6. github-actions commented on Sep 21, 2025

    @github-actions

    Here are some similar issues that might help you. Please check if they can solve your problem.


    Possible solution (Extracted from existing issue, might be incorrect; please verify carefully)

    Solution 1:

    Perform a clean installation of Azure CLI:

    1. Go to Control Panel > Uninstall a program, uninstall Microsoft Azure CLI.
    2. Delete C:\Program Files\Microsoft SDKs\Azure\CLI2 (for x64) or C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2 (for x86).
    3. Reinstall Azure CLI from scratch using the MSI installer.

    This resolves the issue by ensuring no conflicting files remain from previous installations.

    Reference:

    Solution 2:

    Repair the Azure CLI installation by reinstalling the required Python package:

    Open an administrator command prompt and run:

    "C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe" -m pip install pywin32==311 --force-reinstall
    

    This fixes the issue by repairing the PyWin32 dependency.

    Reference:

    Solution 3:

    Uninstall and reinstall Azure CLI using winget:

    1. Uninstall Azure CLI:
    winget uninstall --id Microsoft.AzureCLI -e
    
    1. Delete the contents of C:\Program Files\Microsoft SDKs\Azure\CLI2 if not automatically removed.
    2. Reinstall Azure CLI:
    winget install --id Microsoft.AzureCLI -e -s winget
    

    This ensures a clean installation and resolves the issue.

    Reference:

    Powered by issue-sentinel

  7. added this to the Backlog milestone on Sep 21, 2025
  8. eliassal commented on Sep 21, 2025

    @eliassal
    Author

    I removed az cli from settings, reinstalled and it is working fine now

  9. jiasli commented on Sep 23, 2025

    @jiasli
    Contributor

    Duplicate of #32045

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

ARMaz resource/group/lock/tag/deployment/policy/managementapp/account management-groupAuto-AssignAuto assign by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamPossible-SolutionSimilar-IssueUpgradeaz upgradecustomer-reportedIssues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions