Azure CLI 2.77.0 is broken: ImportError: DLL load failed while importing win32file: The specified module could not be found.
Describe the bug
I have just installed Azure CLI version 2.77.0 and if I then run 'az upgrade' or 'az version' I get the error shown below.
Related command
'az upgrade' or 'az version'
Errors
Traceback (most recent call last):
File "
Issue script & Debug output
Traceback (most recent call last):
File "
Expected behavior
The command 'az version' should show me the current installed version, not an error.
Environment Summary
az --version isn't working right now. See below for disappointing details.
Additional context
No response
Thank you for opening this issue, we will look into it.
Here are some similar issues that might help you. Please check if they can solve your problem.
- #17986
Possible solution (Extracted from existing issue, might be incorrect; please verify carefully)
Solution 1:
I was able to solve it by reinstalling pywin32 with a terminal "Run as Administrator":
& "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe" -m pip install pywin32==228 --force-reinstall
Though the root cause remains unknown...
Reference:
- https://github.com/azure/azure-cli/issues/17986#issuecomment-834372349
- https://github.com/azure/azure-cli/issues/17986#issuecomment-834454489
- https://github.com/azure/azure-cli/issues/17986#issuecomment-3198589072
Solution 2:
As a fresh installation works fine, it's very likely some remnants of the old installation are interfering with the latest version. Another solution worth trying is to:
- Go to Control Panel > Uninstall a program, uninstall Microsoft Azure CLI.
- Delete
C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2. - Reinstall Azure CLI from scratch.
Please kindly let us know if it solves the issue.
Reference:
- https://github.com/azure/azure-cli/issues/17986#issuecomment-834607007
- https://github.com/azure/azure-cli/issues/17986#issuecomment-834760580
- https://github.com/azure/azure-cli/issues/17986#issuecomment-836643857
Powered by issue-sentinel
@plynch66, beat me to filing this by a couple of minutes.
Same error here. Running on Windows 11 on an ARM64 Surface Laptop
I've just rolled back to 2.76.0 and it is working fine. The issue is clearly with version 2.77.0
We were able to recover after a simple reinstall. If it's relevant we also switched to the x64 version
I did a re-install using azure-cli-2.77.0-x64 and it did not work for me. Still getting the same error.
+1
Ditto on running into this error. Downgrading to 2.76.0.
We were able to recover after a simple reinstall. If it's relevant we also switched to the x64 version
If you switched to a different architecture then you didn't do a 'simple reinstall' you did a whole new installation. I was already using the x64 CLI and a reinstall of that still failed. A complete uninstall and reinstall also fails.
I found the same problem, reverted to 2.76
Same issue. Win 11.
Tried Solution 1:
PS C:\Program Files\Microsoft SDKs\Azure\CLI2> .\python.exe -m pip install pywin32==228 --force-reinstall ERROR: Could not find a version that satisfies the requirement pywin32==228 (from versions: 307, 308, 309, 310, 311) ERROR: No matching distribution found for pywin32==228
Had to change the path to the x64 directory as the solution provided the path to x86
Not keen on trying Solution 2 as all extensions also needs to be reinstalled.
UPDATE:
PS C:\Program Files\Microsoft SDKs\Azure\CLI2> .\python.exe -m pip install pywin32==311 --force-reinstall worked for me
Tried Solution 1:
PS C:\Program Files\Microsoft SDKs\Azure\CLI2> .\python.exe -m pip install pywin32==228 --force-reinstall ERROR: Could not find a version that satisfies the requirement pywin32==228 (from versions: 307, 308, 309, 310, 311) ERROR: No matching distribution found for pywin32==228
Had to change the path to the x64 directory as the solution provided the path to x86
Not keen on trying Solution 2 as all extensions also needs to be reinstalled.
UPDATE:
PS C:\Program Files\Microsoft SDKs\Azure\CLI2> .\python.exe -m pip install pywin32==311 --force-reinstall worked for me
Ok, so I was about to start running through the process of trying Solution 1 above.
The first step for me was to upgrade again from 2.76.0 to 2.77.0 (I do this using Powershell to download and install the MSI from this location : https://aka.ms/installazurecliwindowsx64) and then start to force-reinstall of pywin32
I didn't get that far - after running the upgrade (for the 3rd or 4th time in the last 24 hours) it has now decided that it works. I didn't need to reinstall any extensions even though I had previously done a complete uninstall.
I've just rolled back to 2.76.0 and it is working fine. The issue is clearly with version 2.77.0
I did the same and we are now configuring Intune to roll-back all clients to 2.76.0
I experienced this same issue while running az login. I attempted the modified "Solution 1" (.\python.exe -m pip install pywin32==311 --force-reinstall), but that did nothing. I finally just uninstalled completely, then downloaded the x64 msi package (I previously had x64 version installed) and installed it and it all worked fine after that.
UPDATE:
PS C:\Program Files\Microsoft SDKs\Azure\CLI2> .\python.exe -m pip install pywin32==311 --force-reinstall worked for me
This worked for us, and to get az ssh working, we also had to add rpds-py:
cd C:\Program Files\Microsoft SDKs\Azure\CLI2
.\python.exe -m pip install pywin32==311 --force-reinstall
.\python.exe -m pip install rpds-py
Windows 11 ARM64, solution 2 worked.
Not keen on trying Solution 2 as all extensions also needs to be reinstalled.
Extensions are installed in the user folder %USERPROFILE%\.azure\cliextensions and won't be deleted when you delete C:\Program Files\Microsoft SDKs\Azure\CLI2.
I cannot reproduce with a clean installation.
As pointed out in https://github.com/Azure/azure-cli/issues/17986#issuecomment-834607007, the MSI installer may fail to update certain files related to PyWin32 which causes conflicts with the latest installation.
Please follow below steps to do a clean installation:
- Go to Control Panel > Uninstall a program , uninstall Microsoft Azure CLI
- Delete
C:\Program Files\Microsoft SDKs\Azure\CLI2(for x64) orC:\Program Files (x86)\Microsoft SDKs\Azure\CLI2(for x86) - Install the latest Azure CLI from scratch
Please kindly let us know if it solves the issue.
I cannot reproduce with a clean installation.
As pointed out in #17986 (comment), the MSI installer may fail to update certain files related to PyWin32 which causes conflicts with the latest installation.
Please follow below steps to do a clean installation:
- Go to Control Panel > Uninstall a program , uninstall Microsoft Azure CLI
- Delete
C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2- Install the latest Azure CLI from scratch
Please kindly let us know if it solves the issue.
There is no C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2 folder if you run x64 version like I do I followed...
- Uninstall from Control Panel
- Deleted C:\Program Files\Microsoft SDKs\Azure\CLI2 (there was a lib folder left behind by Uninstall)
- Installed 2.77.0 x64 edition again (download of the msi file was very sloooow right now)
Result was what seems to be a working Az CLI :-)
I suggest you to reproduce it you install 2.76.0 and then run "az upgrade" that's when my broke.
There is no C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2 folder if you run x64 version like I do
I have updated my original post to include the path for x64 package.
I suggest you to reproduce it you install 2.76.0 and then run "az upgrade" that's when my broke.
I did, but I still cannot reproduce it. It seems to be related to the MSI installer.
PS C:\Users\xxx> az upgrade
This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
Your current Azure CLI version is 2.76.0. Latest version available is 2.77.0.
Please check the release notes first: https://learn.microsoft.com/cli/azure/release-notes-azure-cli
Do you want to continue? (Y/n): y
Updating Azure CLI with MSI from https://aka.ms/installazurecliwindowsx64
Downloading MSI to C:\Users\xxx\AppData\Local\Temp\azure-cli-msi\azure-cli-2.77.0-x64.msi
Installation started. Please complete the upgrade in the opened window.
To update extensions, please run `az upgrade` again after completing the upgrade.
PS C:\Users\xxx> az -v
azure-cli 2.77.0
core 2.77.0
telemetry 1.1.0
Extensions:
ssh 2.0.6
Dependencies:
msal 1.34.0b1
azure-mgmt-resource 23.3.0
Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe'
Config directory 'C:\Users\xxx\.azure'
Extensions directory 'C:\Users\xxx\.azure\cliextensions'
Python (Windows) 3.13.7 (tags/v3.13.7:bcee1c3, Aug 14 2025, 14:15:11) [MSC v.1944 64 bit (AMD64)]
Legal docs and information: aka.ms/AzureCliLegal
Your CLI is up-to-date.
@jiasli The issue I got after az upgrade might then be related to even older versions... I'm not sure what version I started with (original MSI), but I think it was 2.61.0... from there I think I have been doing az upgrade. It seems anyhow that a "clean" install of 2.77.0 would be recommended to start over with the python dependencies.
Me and multiple coworkers had the same issue this morning after an automated choco update, that upgraded az cli from 2.76 to 2.77 overnight. The solution for us was to completely remove the broken 2.77 installation and install from scratch. Thanks
Using chocolatey.
Performing an upgrade with choco upgrade will result in this issue.
How I fixed it on my machine:
Uninstall using choco uninstall azure-cli.
Check the "Installed Apps" control panel. Uninstall any instances of "Azure Cli"
Reboot
Reinstall using choco install azure-cli
Works ok for me on ARM - fresh install today, not an upgrade
same issue, upgrade from 2.76.0 to 2.77.0 didn't work. I had to uninstall/install to resolve the issue.
winget remove --id Microsoft.AzureCLI winget install --id Microsoft.AzureCLI
PS C:\> az --version
azure-cli 2.77.0
core 2.77.0
telemetry 1.1.0
Extensions:
account 0.2.5
azure-devops 0.26.0
Dependencies:
msal 1.34.0b1
azure-mgmt-resource 23.3.0
Clean reinstall worked for me too. Windows 11.
I finally have it working for me. I had to:
winget uninstall --id Microsoft.AzureCLI -e- delete contents of
C:\Program Files\Microsoft SDKs\Azure\CLI2\ winget install --id Microsoft.AzureCLI -e -s winget
I finally have it working for me. I had to:
winget uninstall --id Microsoft.AzureCLI -e- delete contents of
C:\Program Files\Microsoft SDKs\Azure\CLI2\winget install --id Microsoft.AzureCLI -e -s winget
Thank you, @algonzalez-wf - this worked perfectly! Note: deleting the CLI2 directory was not needed, as the uninstall automatically removed this directory.
Cheers!
Using chocolatey.
Performing an upgrade with
choco upgradewill result in this issue.How I fixed it on my machine:
Uninstall using
choco uninstall azure-cli. Check the "Installed Apps" control panel. Uninstall any instances of "Azure Cli" Reboot Reinstall usingchoco install azure-cli
After the uninstall completed there were a number of files left under C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\pip. I removed these by hand, along with any extension directories, as these did not get detected correctly on re-install.