Python
macos
pip
MSSQL
python2.7

macOS High Sierra で mssql-cli をセットアップする方法

はじめに

mssql-cli とは Ignite 2017 で発表された Python ベースの SQL Server の操作用のマルチプラットフォーム対応の新しいコマンドラインツールです。
macOS High Sierra で実際に使用する方法について備忘録がてら残しておきます。

前提環境

  • Python

手順

実際はこの3行をコピペ実行するだけです。

$ sudo easy_install pip
$ sudo pip install --upgrade pip
$ sudo pip install mssql-cli --ignore-installed six

参考にターミナルのログを貼っておきます。

pip のインストール

Mihos-MacBook:Data miyamam$ sudo easy_install pip
Password:
Searching for pip
Reading https://pypi.python.org/simple/pip/
Best match: pip 9.0.1
Downloading https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9
Processing pip-9.0.1.tar.gz
Writing /tmp/easy_install-Ggi2_3/pip-9.0.1/setup.cfg
Running pip-9.0.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-Ggi2_3/pip-9.0.1/egg-dist-tmp-Tirk3b
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires'
  warnings.warn(msg)
warning: no previously-included files found matching '.coveragerc'
warning: no previously-included files found matching '.mailmap'
warning: no previously-included files found matching '.travis.yml'
warning: no previously-included files found matching '.landscape.yml'
warning: no previously-included files found matching 'pip/_vendor/Makefile'
warning: no previously-included files found matching 'tox.ini'
warning: no previously-included files found matching 'dev-requirements.txt'
warning: no previously-included files found matching 'appveyor.yml'
no previously-included directories found matching '.github'
no previously-included directories found matching '.travis'
no previously-included directories found matching 'docs/_build'
no previously-included directories found matching 'contrib'
no previously-included directories found matching 'tasks'
no previously-included directories found matching 'tests'
creating /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg
Extracting pip-9.0.1-py2.7.egg to /Library/Python/2.7/site-packages
Adding pip 9.0.1 to easy-install.pth file
Installing pip script to /usr/local/bin
Installing pip2.7 script to /usr/local/bin
Installing pip2 script to /usr/local/bin

Installed /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip

pip のアップデート

Mihos-MacBook:Data miyamam$ sudo pip install --upgrade pip
The directory '/Users/miyamam/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/miyamam/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already up-to-date: pip in /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg

mssql-cli のインストール

Mihos-MacBook:Data miyamam$ sudo pip install mssql-cli --ignore-installed six
The directory '/Users/miyamam/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/miyamam/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting mssql-cli
  Downloading mssql_cli-0.9.0-py2.py3-none-macosx_10_11_intel.whl (33.2MB)
    100% |████████████████████████████████| 33.2MB 39kB/s 
Collecting six
  Downloading six-1.11.0-py2.py3-none-any.whl
Collecting Pygments>=2.0 (from mssql-cli)
  Downloading Pygments-2.2.0-py2.py3-none-any.whl (841kB)
    100% |████████████████████████████████| 849kB 1.5MB/s 
Collecting humanize>=0.5.1 (from mssql-cli)
  Downloading humanize-0.5.1.tar.gz
Collecting cli-helpers<1.0.0,>=0.2.3 (from mssql-cli)
  Downloading cli_helpers-0.2.3-py2.py3-none-any.whl
Collecting prompt-toolkit<1.1.0,>=1.0.10 (from mssql-cli)
  Downloading prompt_toolkit-1.0.15-py2-none-any.whl (247kB)
    100% |████████████████████████████████| 256kB 2.0MB/s 
Collecting click>=4.1 (from mssql-cli)
  Downloading click-6.7-py2.py3-none-any.whl (71kB)
    100% |████████████████████████████████| 71kB 2.6MB/s 
Collecting wheel>=0.29.0 (from mssql-cli)
  Downloading wheel-0.30.0-py2.py3-none-any.whl (49kB)
    100% |████████████████████████████████| 51kB 4.7MB/s 
Collecting sqlparse<0.3.0,>=0.2.2 (from mssql-cli)
  Downloading sqlparse-0.2.4-py2.py3-none-any.whl
Collecting future>=0.16.0 (from mssql-cli)
  Downloading future-0.16.0.tar.gz (824kB)
    100% |████████████████████████████████| 829kB 1.3MB/s 
Collecting configobj>=5.0.6 (from mssql-cli)
  Downloading configobj-5.0.6.tar.gz
Collecting applicationinsights>=0.11.1 (from mssql-cli)
  Downloading applicationinsights-0.11.1.tar.gz (44kB)
    100% |████████████████████████████████| 51kB 3.6MB/s 
Collecting enum34>=1.1.6 (from mssql-cli)
  Downloading enum34-1.1.6-py2-none-any.whl
Collecting terminaltables>=3.0.0 (from cli-helpers<1.0.0,>=0.2.3->mssql-cli)
  Downloading terminaltables-3.1.0.tar.gz
Collecting backports.csv>=1.0.0 (from cli-helpers<1.0.0,>=0.2.3->mssql-cli)
  Downloading backports.csv-1.0.5-py2.py3-none-any.whl
Collecting wcwidth (from prompt-toolkit<1.1.0,>=1.0.10->mssql-cli)
  Downloading wcwidth-0.1.7-py2.py3-none-any.whl
Installing collected packages: Pygments, humanize, terminaltables, backports.csv, cli-helpers, wcwidth, six, prompt-toolkit, click, wheel, sqlparse, future, configobj, applicationinsights, enum34, mssql-cli
  Running setup.py install for humanize ... done
  Running setup.py install for terminaltables ... done
  Running setup.py install for future ... done
  Running setup.py install for configobj ... done
  Running setup.py install for applicationinsights ... done
Successfully installed Pygments-2.2.0 applicationinsights-0.11.1 backports.csv-1.0.5 cli-helpers-0.2.3 click-6.7 configobj-5.0.6 enum34-1.1.6 future-0.16.0 humanize-0.5.1 mssql-cli-0.9.0 prompt-toolkit-1.0.15 six-1.11.0 sqlparse-0.2.4 terminaltables-3.1.0 wcwidth-0.1.7 wheel-0.30.0

参考資料