SE の雑記

SQL Server の情報をメインに Microsoft 製品の勉強内容を日々投稿

ML Services をインストールせずに、Revoscalepy を使用する (Ubuntu)

leave a comment

先日、ML Services をインストールせずに、Revoscalepy を使用する という投稿を書きましたが、Windows 版だけでなく、Linux 版でも ML Services をインストールすることなく、Revoscalepy を使用することができますのでメモとして。
(正確には、Linux 環境では ML Services ではなく、ML Server になると思いますが)

ドキュメントとしては、How to install custom Python packages and interpreter locally on Windows の Install on Linux の段落となります。

Linux 環境は、Ubuntu でしか試していないのですが、Ubuntu の場合hは、2017/10/29 時点のドキュメントの内容だとインストールできないと思います。
なぜなら、wget でしている URL だと404 になるから…。
image
pyodbc で SQL Server に接続するために、mssql-tools も一緒にインストールしていますが、次のようなシェルスクリプトでインストールできるかと。

sudo apt-get install -y curl
sudo curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
sudo curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install -y mssql-tools unixodbc-dev
wget https://packages.microsoft.com/ubuntu/16.04/prod/pool/main/m/microsoft-mlserver-python-9.2.1/microsoft-mlserver-python-9.2.1.deb
wget https://packages.microsoft.com/ubuntu/16.04/prod/pool/main/m/microsoft-mlserver-packages-py-9.2.1/microsoft-mlserver-packages-py-9.2.1.deb
sudo dpkg -i microsoft-mlserver-python-9.2.1.deb
sudo dpkg -i microsoft-mlserver-packages-py-9.2.1.deb

インストールが完了すると次のようなメッセージが表示されます。

Anaconda is a Python distribution released by Continuum Analytics, Inc.
To enable your use of this feature, the Python runtime and certain Python packages
from Anaconda will be downloaded to your machine under the licenses provided to you by Continuum Analytics and its licensors.
Microsoft is making these packages available to you for convenience and does not support this software.
More information about Anaconda is available from Continuum Analytics.
By downloading this software and installing it on your machine you are
agreeing to accept patches and updates to this software.
By using Microsoft Machine Learning Server you agree to the privacy policy
which includes anonymous usage collection.
You can opt-out anytime by launching python and running the following commands:
import revoscalepy
revoscalepy.rx_privacy_control(False)
INFO: Creating symlink /usr/bin/mlserver-python => /opt/microsoft/mlserver/9.2.1/bin/python/../../bin/python/python

「mlserver-python」でインストールされた Python が起動できますので、ここから、revoscalepy が利用可能な Python が利用できるようになります。
VS Code から使用する場合はユーザー設定に次の設定を追加することで、revoscalepy を使った開発ができるかと。

"python.pythonPath":"mlserver-python"
Share

Written by Masayuki.Ozawa

10月 29th, 2017 at 11:51 pm

Leave a Reply