If needed, install and configure Python to run code to run on a Secure Agent machine.
Informatica packages a default Python version in the Secure Agent installation. If this version meets your needs, you can use it without further configuration. If you need third-party libraries or a specific version of Python, install and configure a custom Python installation.
Note:
You can't create a custom Python installation when you use a serverless runtime environment.
To install and configure Python, complete the following tasks:
1Install the prerequisite packages on the Secure Agent machine.
2Download the version of Python that you want to install on the Secure Agent machine and extract the files.
3Prepare the installation directory.
4Compile and build the Python installation.
5Set environment variables to allow the Secure Agent machine access to the installation.
6Verify the installation contains the correct folders.
7Install the str2bool library and any additional third-party libraries.
8Copy the installation to the Secure Agent machine.
9If your installation uses third-party libraries, verify their installation.
10Configure the mapping task to use the custom Python installation.
Step 1. Install prerequisite packages
Before you install Python, make sure that the Secure Agent machine has the required packages.
Install the following packages on the agent machine:
•libffi
•OpenSSL
•zlib
Use the appropriate installation commands for your package manager. For example, to use the yum package manager, run the following commands:
This command downloads the Python distribution in the home directory.
3To extract the contents, run the following command :
tar -xvf <file name>
For example, to extract the contents of the file Python-3.6.5.tgz, run the following command:
tar -xvf Python-3.6.5.tgz
The extracted files appear in the directory ~/Python-3.6.5.
Step 3. Prepare a directory to install Python
Specify a location to contain the Python installation. To prepare an installation directory, run commands to create a directory and set it as the working directory.
1To create a directory under the home directory, run the following command:
mkdir <directory name>
2To create an environment variable called $workingdir and set the value to the present working directory, run the following command:
export workingdir=`pwd`
3To verify the $workingdir environment variable, run the following command:
echo $workingdir
Step 4. Install Python
Run commands to compile and build the Python installation.
1Use cd to navigate to the directory where you extracted the Python distribution. For example:
cd Python-3.6.5
2Compile Python under the working directory. For example, run the following command:
If your Python installation uses third-party libraries, make sure they are installed on the Secure Agent machine.
1To change directories to the Secure Agent machine, run the following command:
cd <Secure Agent installation directory>/ext/python/
2To invoke the Python interpreter, run the following command:
bin/python3
3Use import commands to verify the installation of each third-party library. For example, run the following commands:
import numpy import sklearn
4Verify that the import statement is successful for each Python third-party library that you installed. Then, you can press Ctrl+D to exit the Python interpreter.
Step 10. Configure the mapping task
After you create a mapping with a Python transformation, configure the mapping task to use the custom Python installation.
In the mapping task, configure an advanced session property to specify the locations of the custom Python installation directory and Python executable.
1In the mapping task advanced session properties, click Add.
2For the session property name, select Custom Properties.
3For the session property value, enter the following custom properties:
Property
Description
infaspark.pythontx.executorEnv.PYTHONHOME
The location of the Python installation directory on the Secure Agent machine. The default value is $INFA_HOME/python3.
infaspark.pythontx.exec
The location of the Python executable on the Secure Agent machine. The default value is $INFA_HOME/python3/bin/python3.
Use &: to spearate the key-value pairs. For example, you might enter the following value: infaspark.pythontx.executorEnv.PYTHONHOME=$INFA_HOME/python&:infaspark.pythontx.exec=$INFA_HOME/python/bin/python3