Categories

Versions

You are viewing the RapidMiner Studio documentation for version 9.4 -Check here for latest version

Install the Python Scripting extension

ThePython Scripting extensionincludes the OperatorExecute Python, that makes it possible to run Python code inside a RapidMiner process. The Operator supports a variety of Python interpreters/distributions, including the popularAnacondadistribution andvirtualenvwrapperenvironments.

Install

安装延期nsion, go to theExtensionsmenu, open theRapidMinerMarketplace (Updates and Extensions), and search forPython Scripting. For more detail, seeAdding extensions.

Configure: choose the default Python

Even without any configuration, the extension will attempt to detect a Python environment / executable. IfAnacondais installed, it will by default use thebaseconda environment. Otherwise it will use the first executable it finds.

Before using the extension for the first time, you should configure its default settings: the location of your Python interpreter or the name of your virtual environment. Notice, however, that you canoverride the default settingswithin the OperatorExecute Pythonby unchecking the advanced parameteruse default python.

To configure the extension with the default Python, take the following steps:

  1. Open thePreferencesdialog (on Mac OS go to theRapidMiner->Preferences...menu, on other systems use theSettings->Preferences...menu).

  2. Go to thePython Scriptingtab.

  3. If the folder containing your Python interpreter (or conda/virtualenvwrapper) is not in your system path, editSearch paths和包括它。

  4. Based on your needs, set the package manager to one of the following:

    • If you are usingAnaconda(orMiniconda), select theconda (anaconda)option from the drop-down list (this is the default). Theconda environmentparameter appears. From the drop-down list select the name of the environment you want to use. Click therefreshbutton, if you don't see your environment in the list.

    • If you are usingvirtualenvwrapper, select thevirtualenvwrapperoption from the drop-down list. Thevenvw environmentparameter appears. From the drop-down list select the name of the environment you want to use. Click therefreshbutton, if you don't see your environment in the list.

    • If you are using some other Python executable/distribution, select thespecific python binariesoption from the drop-down list. ThePython binary pathparameter appears. The extension scans some commonly used directories plus the additional directories you provided inSearch pathsfor Python executables; this scan may take some time. Select the desired Python executable from the drop-down menu. Click therefreshbutton if you don't see it in the list. Alternatively, locate your executable and provide the full path by typing it into the text box or by selecting it from theopen filedialog.

    When you click therefresh button, it may take a few seconds until the drop-down list is updated.

  5. Once you have selected the desired environment/executable, click theTestbutton. If your configuration is successful, you may see something like this:

    If testing fails, try to select a different environment/executable or address the problems shown in the dialog. Most probably you will need to install or upgrade some Python packages in your environment/executable.

  6. ClickOKto close the test result dialog. ClickOKone more time to close thePreferencesdialog and save the new settings.

Now you are ready to use theExecute Pythonoperator.

Execute Python: override the default Python

ThePython Scriptingextension supports conda and virtualenvwrapper virtual environments. Virtual environments make package management simpler when you are working on multiple projects simultaneously. The OperatorExecute Pythonnormally uses the default environment defined in thePreferencesdialog, but you can use any environment you like by unchecking the parameteruse default pythonin the Parameters Panel. Then followthe instructions aboveto select a non-default environment forExecute Python.

The benefit of using virtual environments is that processes are more portable -- just make sure you have the same Python environment with the same packages installed on other instances of RapidMiner Studio or RapidMiner Server.