I came through the same issue and did some research. I found that someone has created a bug for the same issue under the azure/cli repository. You can find that issue here. I am providing the same solution here which was very easy and fixed my issue:
Most probably the Brew is broken and needs some patching or fixing. So run brew doctor
command which will give you a summary about what is happening.
Below is what I got:
mymac:bin sidmishra$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!
Warning: The following directories do not exist:
/usr/local/sbin
You should create these directories and change their ownership to your account.
sudo mkdir -p /usr/local/sbin
sudo chown -R $(whoami) /usr/local/sbin
Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected dylibs:
/usr/local/lib/LibSideSyncOSX9.dylib
/usr/local/lib/ss_conn_lib.dylib
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
python
The awesome stuff about the command brew doctor
is that it not only tells you issues but also suggests you the solution steps in most of the cases.
So, I ran all the commands suggested by the brew and to link I ran the following command:
brew link python
Above command threw me an error:
mymac$ brew link python
Linking /usr/local/Cellar/python/3.7.1... Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks/Python.framework
It seems that /urs/local/Frameworks
doesn't have enough rights for my current user. So, I ran the following command and gave enough rights to my current user:
sudo chown -R $(whoami) /usr/local/Frameworks/
After running above command I ran linking command again, and it worked!!!
mymac$ brew link python
Linking /usr/local/Cellar/python/3.7.1... 1 symlinks created
Now run following command to get the current selected python version:
python --version
Above command should give you 3.7.1
(as of 21st Dec 2018) or new version for the python. There might be a chance that your Mac would have python2
set by default. If the version is not python3
then you have to a couple of steps to use the latest python3
over python2
version. Here are the steps:
Using Shell:
- Open
~/.bash_login
or ~/.bash_profile
or ~/.cshrc
or ~/.profile
or ~/.tcshrc
or ~/.zprofile
, whatever shell you are using for commands, in edit mode. You may have to use sudo
to edit them.
Add following steps to it:
PATH="/Library/Frameworks/Python.framework/Versions/3.2/bin:${PATH}"
export PATH
Also, add following for backup:
alias python=python3
OR
Using homebrew:
Run following commands to unlink python2 and link python3:
mymac$ brew unlink python@2
mymac$ brew link python@3
Above will unlink python2 and link python3.
Hope some of you will get helped from this answer.
Good Day!!!