Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Sv translation
languageen

In BellaDati ML Studio it is possible to use Python libraries and scripts. To be able to use them, Anaconda needs to be installed on the server.

Info
titleRecommendation

Python version 3.8.12 and higher is recommended

Settings up Python

  1. Download Anaconda from official site and install it (both versions 2.7 and 3.8 are supported). You can also install regular Python from official sites.
  2. Copy path to file python.exe which is located in the folder where Anaconda was installed (for example C:\Anaconda2\python.exe or /usr/bin/python).
  3. Open BellaDati ML Studio and go to Settings.
     
  4. Paste the path to python.exe to "Path to Python executable" field.
  5. Save the Settings.

Adding and removing Python Scripts in Projects

Python scripts can be attached to a project by uploading them from the Files sections.

It is also possible to remove the file from the project by clicking on the delete icon.

Setting up pylint

  1. Check if you have already installed pylint. If so continue to #8
  2. If you are missing pylint make sure you have installed pip. If you have installed pip continue to #7
  3. Install pip. Go to python folder and navigate to Scripts subfolder
  4. Run command

    Code Block
    languagepowershell
    curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py


  5. Navigate to folder where python.exe is located. Should be in parrent folder.
  6. Run command and specify path to file downloaded in 4th step

    Code Block
    python.exe Scripts\get-pip.py


  7. Navigate back to Script folder and run command to install pylint

    Code Block
    pip install pylint


  8. Open BellaDati ML Studio and go to Settings. Same as in #3 in Setting up Python
  9. Paste the path to pylint.exe to "Path to Pylint" field.
  10. Save the Settings.


You can install any additional dependencies in Script folder using

Code Block
pip install <module_name>


USING PYTHON SCRIPTS IN PROJECTS

Python script can be executed from the code by using function executePythonScript(). This function is used with several parameters. The first one is mandatory and it is always the Python script, either name of the file or directly the Python code. The rest of parameters if optional. It can be InputStream parameter and (or) any number of String parameters.

Code Block
languagejava
titleExamples of function executePythonScript()
executePython(String script, String... params)
executePython(String script, InputStream is, String... params)
executePythonScript(String file, String... params)
executePythonScript(String file, InputStream is, String... params)

Troubleshooting

Error "Python executable is not defined or does not exist." is displayed.

Please make sure that you have set the correct path to the file python.exe. This error can also happen when BellaDati cannot access the file because it does not have correct access rights, e. g. when the Anaconda folder is located inside user's home directory (C:\Users\nameofuser\Anaconda2).


Tip
titlelinux ubuntu Python

Detail description see Python installation -linux Ubuntu page


Sv translation
languageja

BellaDati ML Studioでは、Pythonライブラリとスクリプトを使用できます。それらを使用できるようにするには、Anacondaをサーバーにインストールする必要があります。


Info
title推奨

Pythonバージョン3.8.12以降を推奨しています


PythonのAnaconda環境構築

  1. 公式サイトからAnacondaをダウンロードしてインストールします(バージョン2.7と3.7の両方がサポートされています)。

  2. Anacondaがインストールされたフォルダーにあるpython.exeファイルへのパスをコピーします(例えば、C:\Anaconda2\python.exeまたは/usr/bin/python)。
  3. BellaDati ML Studioを開き、 設定に移動します。
     
  4. python.exeへのパスを「Path to Python executable」フィールドに貼り付けます。

  5. 設定を保存します。

プロジェクトでのPythonスクリプトの追加と削除

Pythonスクリプトは、ファイルセクションからアップロードすることでプロジェクトに添付できます。

削除アイコンをクリックして、プロジェクトからファイルを削除することもできます。


pylintのセットアップ

  1. すでにpylintがインストールされているかどうか確認してください。インストールされている場合は、#8へ進んでください。
  2. pylintがない場合は、pipがインストールされていることを確認してください。pipがインストールされている場合、#7に進みます。
  3. pipをインストールします。python フォルダに移動し、Scripts サブフォルダに移動します。
  4. コマンドを実行します。

    curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py


  5. python.exeがあるフォルダに移動します。parrentフォルダの中にあります。
  6. コマンドを実行し、第4ステップでダウンロードしたファイルのパスを指定します。

    python.exe Scripts\get-pip.py


  7. Script フォルダに戻り、pylint をインストールするコマンドを実行します。

    pip install pylint


  8. BellaDati ML Studioを起動し、「設定」を開きます。Pythonのセットアップの#3と同じです。
  9. Pylintへのパス "欄にpylint.exeのパスを貼り付けます。
  10. 設定を保存します。


Script フォルダに追加でインストールする場合は、次のようにします。

pip install <module_name>


プロジェクトでのPYTHONスクリプトの使用

Pythonスクリプトは、executePythonScript()関数を使用してコードから実行できます。この関数はいくつかのパラメーターとともに使用されます。最初のパラメーターえは必須で、常にPythonスクリプトであり、ファイル名か直接Pythonコードを使用します。残りのパラメーターはオプションです。 InputStreamパラメーターおよび(または)任意の数のStringパラメーターにすることができます。

Code Block
languagejava
titleExamples of function executePythonScript()
executePython(String script, String... params)
executePython(String script, InputStream is, String... params)
executePythonScript(String file, String... params)
executePythonScript(String file, InputStream is, String... params)


トラブルシューティング

「Python実行可能ファイルが定義されていないか、存在しません。」エラーが表示されています。

python.exeファイルへの正しいパスを設定したことを確認してください。このエラーは、BellaDatiが正しいアクセス権を持っていないためにファイルにアクセスできない場合にも発生します。例えば、Anacondaフォルダーがユーザーのホームディレクトリ内にある場合(C:\Users\ nameofuser\Anaconda2)。(C:\Users\nameofuser\Anaconda2).


Tip
titlelinux ubuntu Python

詳細はPythonのインストール -linux Ubuntuのページをご覧ください。


...