-
Notifications
You must be signed in to change notification settings - Fork 3k
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
No module named azure.cli.__main__; #19027
Comments
@jiasli for awareness |
+1 Environment summary |
Just in case: the same after installing 2.27.0. |
8 days and no reply at all, is there anyone looking at these problems / bugs? |
It was added to the milestone 7 days ago and labeled. I think someone can be investigating it ;) |
MacOS Bir Sur 1.15.1 here and no issues. Which version of Python is installed in your case? ( |
Can you include this info:
|
Could be related to #16417. I tested on Big Sur 11.5.1 with Intel chip but couldn't repro this issue. Are you on M1 chip? Azure CLI uses Python 3.8 installed by Homebrew:
|
See below information asked: I am on an Intel MAC (not M1) and last: ~/Documents/POCs/LODH $ ls -l /usr/local/Cellar/azure-cli/2.26.1/libexec/bin/python |
I have upgraded to 2.27 to be on latest release, but issue is the same |
Can you try |
I think the
|
I'm on Intel and have this issue. I can help with tests if needed. |
Can you see my comment just above and post the results of those commands here so we can investigate a bit? |
🚀 which az 🚀 brew --version |
What happens if you try |
/usr/local/Cellar/azure-cli/2.27.0/libexec/bin/python: No module named azure.cli.main; 'azure.cli' is a package and cannot be directly executed |
Guys, any updates? I have the same issue on my mac (macOS 11.5.2, 6-Core Intel Core i7)
|
|
I can confirm. It works after upgrade to 2.27.1. |
I am glad to know it works. We bumped the underlying Python to 3.9 (#18224, #19222, Homebrew/homebrew-core#83088), though I don't exactly know why it fails previously on Python 3.8. Looks like something else installed by Homebrew conflicts with Azure CLI. We never see this problem in the tests of our release pipeline, which run on a clean MacOS 10.14. |
az cli no longer working on my machine, running macOS 11.5.1.
|
I can confirm this issue still exists. I went the extra mile of removing all my installed brew formula (only keeping casks), verifying that all the formula were removed, and then reinstalling only azure-cli so that only that formula and the required dependencies exist. This is on an M1-based MBP on 11.5.
|
Could you help verify if the installation of Azure CLI by Homebrew is correct by running: $ which az
/usr/local/bin/az
$ cat $(which az)
#!/usr/bin/env bash
AZ_INSTALLER=HOMEBREW /usr/local/Cellar/azure-cli/2.27.1/libexec/bin/python -m azure.cli "$@"
# Use python from above output to check 'sys.path'
$ /usr/local/Cellar/azure-cli/2.27.1/libexec/bin/python -c "import sys; print(sys.path)"
['', '/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python39.zip', '/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9', '/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload', '/usr/local/Cellar/azure-cli/2.27.1/libexec/lib/python3.9/site-packages', '/usr/local/lib/python3.9/site-packages']
# Check 'azure' module
$ /usr/local/Cellar/azure-cli/2.27.1/libexec/bin/python -c "import azure; print(azure.__path__)"
['/usr/local/Cellar/azure-cli/2.27.1/libexec/lib/python3.9/site-packages/azure']
# List the path from above output
$ ls /usr/local/Cellar/azure-cli/2.27.1/libexec/lib/python3.9/site-packages/azure
__init__.py
__pycache__
appconfiguration
batch
cli
common
core
cosmos
datalake
graphrbac
identity
keyvault
loganalytics
mgmt
multiapi
profiles
storage
synapse
# Check 'azure.cli' module
$ /usr/local/Cellar/azure-cli/2.27.1/libexec/bin/python -c "import azure.cli; print(azure.cli.__path__)"
_NamespacePath(['/usr/local/Cellar/azure-cli/2.27.1/libexec/lib/python3.9/site-packages/azure/cli'])
# List the path from above output
$ ls /usr/local/Cellar/azure-cli/2.27.1/libexec/lib/python3.9/site-packages/azure/cli
__main__.py
__pycache__
command_modules
core
telemetry
# Check if there are old installations
$ ls --directory /usr/local/Cellar/azure-cli/*/libexec/lib/python*/site-packages/azure/cli |
I think I found my culprit:
I did the following:
Delete all pip cache:
Uninstall pip:
Fix possible old package permissions:
Reinstall python3.9 using brew:
Reinstall azure-cli:
Seems to solve path for the azure module:
This is probably not the solution for everyone (and probably not the best or easiest), but worked for me. |
Follow up from my last comment:
Checking path for the azure module:
This suddenly changed again.
Not a python-guy, but seems obvious that these packages install new modules that get in PATH and breaks the azure-cli installation from homebrew. |
I was starting to run through the new troubleshooting when I discovered the same thing as egilh. Once I got to the interactive import, I saw two paths, one to the homebrew install and one to a local site-packages (/opt/homebrew/lib/python3.9/site-packages/azure for me on am M1 machine). Once I purged those packages, the az command began to work again. |
According to Homebrew/brew#1790, system
Checked the
Python for Formula Authors also doesn't mention this behavior. I asked a question at Homebrew/discussions#2009. |
CauseAs discussed in Homebrew/discussions#2009, this issue is caused by installing Ansible collection for Azure to the system https://github.com/ansible-collections/azure/blob/dev/requirements-azure.txt requires:
The installation of After Homebrew/brew#11611, the virtual environment created by Homebrew
SolutionTo avoid 2 If you has already installed Ansible collection for Azure to the system
|
same for me |
Describe the bug
After installing Azure CLI using homebrew on MacOS, trying first command az login, I got error:
To Reproduce
open MacOS terminal and run:
brew update && brew install azure-cli
az login
Expected behavior
get Azure CLI login instructions
Environment summary
MacOS Catalina 10.15.7
The text was updated successfully, but these errors were encountered: