-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Installing Azure-CLI on OSX 10.11/El Capitan #1682
Description
Installing Azure-cli
OS: OSX 10.11 El Capitan
vscode: vscode-insiders 1.8
Default node.js: 7.3
python/python3: 2.7/3.6
pip/pip3 version: 9.0.1
azure version: 0.10.8(node:4.7.0) // Is this conflicting some kind of way?
I have been trying to use the appservice plan commands on OSX el capitan according to this VS Code demo by @lostintangent at http://code.visualstudio.com/blogs/2017/01/15/connect-nina-e2e#_deploying-your-app. Every time I run something with that command in it, i get the following type of error:
Having a lot of trouble running Azure cli commands so had to do some research.
In order to deploy to Azure via the azure-cli, apparently its best to use an updated production python version which in this case is python3. So we want to install python3 and pip3 but need to do it into a different directory because this mac uses python2.7 internally and we dont want to mess anything up. See http://docs.python-guide.org/en/latest/starting/install/osx/ and this SO post:
http://stackoverflow.com/questions/33535625/python-3-5-for-os-x-el-capitan.
Going to have to figure out how we specify which version to use.
Installing python3 and pip3
I went to the python docs to learn how to install python3. Run brew install python3 in terminal. After this installs, lets check if pip3 is installed or we have to do something else. Got this output:
...
==> Caveats
Pip, setuptools, and wheel have been installed. To update them
pip3 install --upgrade pip setuptools wheel
You can install Python packages with
pip3 install <package>
They will install into the site-package directory
/usr/local/lib/python3.6/site-packages
See: http://docs.brew.sh/Homebrew-and-Python.html
.app bundles were installed.
Run `brew linkapps python3` to symlink these to /Applications.
==> Summary
🍺 /usr/local/Cellar/python3/3.6.0: 3,597 files, 55.7M
Running pip3 install --upgrade pip setuptools wheel per instructions though cant say im sure what this does. Lots of this going on in dev work. I dont know python and I dont know yet what is really going on in my machine. The azure cli pip troubleshooting suggests I use pip3 though, so here we go. This was the terminal output:
klik:~ klik$ pip3 install --upgrade pip setuptools wheel
Requirement already up-to-date: pip in /usr/local/lib/python3.6/site-packages
Collecting setuptools
Using cached setuptools-32.3.1-py2.py3-none-any.whl
Requirement already up-to-date: wheel in /usr/local/lib/python3.6/site-packages
Installing collected packages: setuptools
Found existing installation: setuptools 32.2.0
Uninstalling setuptools-32.2.0:
Successfully uninstalled setuptools-32.2.0
Successfully installed setuptools-32.3.1I did a quick google search to see if brew linkapps python3 causes any major problems. I did not come up with anything so I went ahead and ran it. Output was
klik:~ klik$ brew linkapps python3
Linking: /usr/local/opt/python3/IDLE 3.app
Linking: /usr/local/opt/python3/Python Launcher 3.app
Linked 2 apps to /ApplicationsI checked my python versions to see what was on the machine with python --version, python3 --version, pip --version, pip3 --version. Output was:
klik:~ klik$ python --version
Python 2.7.10
klik:~ klik$ which python
/usr/bin/python
klik:~ klik$ python3 --version
Python 3.6.0
klik:~ klik$ pip --version
pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)
klik:~ klik$ pip3 --version
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
klik:~ klik$ So now I have the recommended python3/pip3 for azure cli. Lets see if azure cli is working now....not working getting the same errors.
Retrying Azure-cli
I lost focus for a second and ran azure -help and az -help. The first one ran but not the second. I then tried the alternative solution in azure-cli troubleshooting on issue on github and ran pip install --pre azure-cli. This gave me the following error after a bunch of terminal output:
...
Permission denied: '/Library/Python/2.7/site-packages/azure_cli-0.1.0b11-py3.5-nspkg.pth'I then tried to run the same command with sudo: sudo and got an error message suggesting I use the python -H flag which, per this stackoverflow post http://stackoverflow.com/questions/27870003/pip-install-please-check-the-permissions-and-owner-of-that-directory, sets the $HOME variable to the target user. Later in that post, its suggested run the command with the --user flag and I did this instead just because it seemed cleaner. So I ran pip install --user --pre azure-cli. So this is almost the same command as the original install instructions except we added the -pre flag. I figured that I was back at the original install instructions workflow and tried running the next step az component update --add appservice. This threw the following error in the terminal:
klik:~ klik$ az component update --add appservice
/usr/bin/python: No module named azure.cliI retried using azure instead of az azure component update --add appservice and go the following output:
error: 'component' is not an azure command. See 'azure help'.
The current mode is: arm (Azure Resource Manager).I have no idea what is going on here. I thought that az was an alias for azure. Even if the alias is not set, component is a command per the azure docs so maybe az doesnt alias azure. At any rate, the alias was not automatically installed as is suggested, if in fact, its an alias.
The next part of the instructions suggested we might have to alter our path variable. I added both python and python3 to the path with no effect.
I ran echo "$PATH" and $PATH with this output:
klik:~ klik$ $PATH
bash: /usr/local/mysql/bin:/Users/klik/google-cloud-sdk/bin:/opt/local/bin:/opt/local/sbin:/Users/klik/.rbenv/shims:/Users/klik/.yarn/bin:/Users/klik/.nvm/versions/node/v7.3.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/share/dotnet:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/local/mysql/bin:/Applications/Wireshark.app/Contents/MacOS:/Users/klik/.rvm/bin:/Users/klik/Library/Python/3.6/bin:/Users/klik/Library/Python/2.7/bin: No such file or directory
klik:~ klik$ echo "$PATH"
/usr/local/mysql/bin:/Users/klik/google-cloud-sdk/bin:/opt/local/bin:/opt/local/sbin:/Users/klik/.rbenv/shims:/Users/klik/.yarn/bin:/Users/klik/.nvm/versions/node/v7.3.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/share/dotnet:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/local/mysql/bin:/Applications/Wireshark.app/Contents/MacOS:/Users/klik/.rvm/bin:/Users/klik/Library/Python/3.6/bin:/Users/klik/Library/Python/2.7/binAny guidance would be greatly appreciated.