opened
chrisdias
username_0
I tried to install the latest CLI from the docs: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-macos?view=azure-cli-latest. I'm pretty sure I installed using brew so I ran:
 
brew update && brew install azure-cli
 
it ran for a while, then this:
 
```
Error: An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /usr/local
Permission denied @ dir_s_mkdir - /usr/local/Frameworks
Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks
```

Tried to do this manually:

``` 
~/src/vscode-docker$ brew link --overwrite python3
Linking /usr/local/Cellar/python3/3.6.4_2... Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks
```
 
So I tried running with sudo and get a big error:

``` 
~/src/vscode-docker$ sudo brew link --overwrite python3
Password:
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
```

If i run `brew upgrade azure-cli` i see:

`Error: azure-cli 2.0.26 already installed`

if i `which az` gives me `/usr/local/bin/az`
unable to update cli using homebrew
issue
created
derekbekoe
username_1
Please provide
```
CLI version (az --version) / OS version / Shell Type (e.g. bash, cmd.exe, Bash on Windows)
```
comment
created
chrisdias
username_0
sorry.  Im on a Mac (10.13.2) using bash. after trying to run az upgrade a few different ways, now i have this:

~/src$ az -v
No module named 'pkg_resources'
Traceback (most recent call last):
  File "/usr/local/Cellar/azure-cli/2.0.26/libexec/lib/python3.6/site-packages/knack/cli.py", line 187, in invoke
    self.show_version()
  File "/usr/local/Cellar/azure-cli/2.0.26/libexec/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 79, in show_version
    print(get_az_version_string())
  File "/usr/local/Cellar/azure-cli/2.0.26/libexec/lib/python3.6/site-packages/azure/cli/core/util.py", line 60, in get_az_version_string
    installed_dists = get_installed_cli_distributions()
  File "/usr/local/Cellar/azure-cli/2.0.26/libexec/lib/python3.6/site-packages/azure/cli/core/util.py", line 51, in get_installed_cli_distributions
    from pkg_resources import working_set
ModuleNotFoundError: No module named 'pkg_resources'
comment
created
derekbekoe
username_1
Are you in a Python virtual environment or have 'az' installed elsewhere on the machine?
comment
created
chrisdias
username_0
i am not in a python virtual environment as far as i know and i may have had az installed elsewhere. i can't remember how i originally installed it. i think there was a .dmg or .zip for mac as well, but that doesn't seem to exist anymore.
comment
created
mattmasteller
username_2
I have very similar issues. Wondering if it has anything to do with running Python 3.6.3 using the Anaconda distribution? 

```bash
$ python --version
Python 3.6.3 :: Anaconda, Inc.
```
comment
created
grimaldou
username_3
Same here, do you have any news?
comment
created
grimaldou
username_3
I solve my case, hope solve yours:

1.- Uninstall Azure CLI (could have an error, it is ok)
`brew uninstall azure-cli`

2.- Update just brew
`brew update`

3.- Upgrade brew
`brew upgrade`

4.- Clean up brew
`brew cleanup`

5.- Reinstall just the Azure CLI
 `brew install azure-cli`

6.- Check the CLI
`az help`

Hope it works for you!
comment
created
pjhayward
username_4
@username_3 's suggestion worked for me after I made sure that Python 3.6.x was properly installed. I used Anaconda to install and activate it in an environment.
comment
created
chrisdias
username_0
It looks like I had originally installed the az CLI using the install script (https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux?view=azure-cli-latest). I cleaned that up using the instructions provided with that page, then installed using homebrew and it works.  Generally.  When I run `az --version` I get this:

```
~/src$ az --version
No module named 'pkg_resources'
Traceback (most recent call last):
  File "/usr/local/Cellar/azure-cli/2.0.28/libexec/lib/python3.6/site-packages/knack/cli.py", line 187, in invoke
    self.show_version()
  File "/usr/local/Cellar/azure-cli/2.0.28/libexec/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 79, in show_version
    print(get_az_version_string())
  File "/usr/local/Cellar/azure-cli/2.0.28/libexec/lib/python3.6/site-packages/azure/cli/core/util.py", line 60, in get_az_version_string
    installed_dists = get_installed_cli_distributions()
  File "/usr/local/Cellar/azure-cli/2.0.28/libexec/lib/python3.6/site-packages/azure/cli/core/util.py", line 51, in get_installed_cli_distributions
    from pkg_resources import working_set
ModuleNotFoundError: No module named 'pkg_resources'
```
comment
created
pjhayward
username_4
Hi Chris,

This happens when your Python environment is not set up correctly. I manage Python versions and environments for different projects with Anaconda. When I run `az —verion` under my standard environment I get the same error as reported below. However, the command works when I change to me Python 3.6.2 environment under which azure-cli was installed. Here is an example of the output it gives me:

 peter@Peters-MacBook-Pro >  source activate py3.6.2
 peter@Peters-MacBook-Pro > az --version
azure-cli (2.0.27)

acr (2.0.21)
acs (2.0.26)
advisor (0.1.2)
appservice (0.1.26)
backup (1.0.6)
batch (3.1.10)
batchai (0.1.5)
billing (0.1.7)
cdn (0.0.13)
cloud (2.0.12)
cognitiveservices (0.1.10)
command-modules-nspkg (2.0.1)
configure (2.0.14)
consumption (0.2.1)
container (0.1.18)
core (2.0.27)
cosmosdb (0.1.19)
dla (0.0.18)
dls (0.0.19)
eventgrid (0.1.10)
extension (0.0.9)
feedback (2.1.0)
find (0.2.8)
interactive (0.3.16)
iot (0.1.17)
keyvault (2.0.18)
lab (0.0.17)
monitor (0.1.2)
network (2.0.23)
nspkg (3.0.1)
profile (2.0.19)
rdbms (0.0.12)
redis (0.2.11)
reservations (0.1.1)
resource (2.0.23)
role (2.0.19)
servicefabric (0.0.10)
sql (2.0.21)
storage (2.0.25)
vm (2.0.26)

Python location '/Users/peter/Anaconda2/envs/py3.6.2/bin/python3.6'
Extensions directory '/Users/peter/.azure/cliextensions'

Python (Darwin) 3.6.2 |Anaconda custom (x86_64)| (default, Jul 20 2017, 13:14:59)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]

Legal docs and information: aka.ms/AzureCliLegal

Hope this helps.

Kind regards,

-- 
Peter Hayward
Data Scientist · Praelexis

Capital Place F · 15 - 21 Neutron Avenue · Technopark · Stellenbosch · 7600
Tel: +27 (0) 72 354 5228 

Email: peterhayward@praelexis.com <mailto:mcelory@praelexis.com>

>
comment
closed
chrisdias
username_0
issue
created
chrisdias
username_0
Update: 

I was was given a tip that my python `setuptools` might have been deleted (see [here]( https://stackoverflow.com/questions/7446187/no-module-named-pkg-resources)). So, I ran:

`curl https://bootstrap.pypa.io/ez_setup.py | python`

but that failed with permission issues to `/Library/Python`. I ran again with `sudo` but that still failed.

After digging around the docs more, I installed `wget` with brew, which in turn notified my that my python was out of date (a bit weird).  So I ran:

`brew upgrade python`

And from there, everything started working.
comment
created
mzaatar
username_5
What worked for me was going to this folder `/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib`
and creating and empty folder called "pkg_resources" and then run 
`az --version `
After that all good, I started installing the azure-iot-developer-kit which was my main goal. Thanks for the tips on this page!
comment
created
derekbekoe
username_1
You could also try`brew doctor` and see if that provides any hints.
comment
created
seattlevine
username_6
I ran
`brew reinstall python3`
to fix this
comment
created
codymullins
username_7
The fix by @username_3 worked after I followed the [instructions here](https://github.com/Homebrew/homebrew-core/issues/19286) by chingNotCHing.
comment
created
raywang
username_8
works for me +1
comment
created
at1012
username_9
Seeing this issue on macos: 

**$ az --version**
azure-cli                         2.0.72 *

command-modules-nspkg               2.0.3
core                              2.0.72 *
nspkg                              3.0.4
telemetry                          1.0.3

Python location '/usr/local/Cellar/azure-cli/2.0.72_1/libexec/bin/python'
Extensions directory '/Users/****/.azure/cliextensions'

Python (Darwin) 3.7.4 (default, Sep  7 2019, 18:27:02)
[Clang 10.0.1 (clang-1001.0.46.4)]

Legal docs and information: aka.ms/AzureCliLegal
You have **2 updates available**. Consider updating your CLI installation

**$ brew update && brew upgrade azure-cli**
Already up-to-date.
**Error: azure-cli 2.0.72_1 already installed**

MacOS Version: Mojave 10.14.6
Shell Type: bash
Not in a virtualenv
comment