Install and configure your Python code to run on a Secure Agent machine. Configure tasks such as setting the advanced session property and installing the Python packages.
Note: You can't create a custom Python installation when you use a serverless runtime environment, so these steps don't apply.
To install and configure Python, complete the following tasks:
1To allow the Python transformation to use third-party libraries, make sure that the runtime environment has access to an installation of Python and the referenced resource files.
2Install the prerequisite packages on the Secure Agent machine.
3Download the version of Python that you want to install on the Secure Agent machine and extract the files.
4Prepare the installation directory.
5Compile and build the installation directory.
6Set environment variables to allow the Secure Agent machine access to the installation.
7Verify the installation contains the correct folders.
8For custom installations, install the str2bool library.
9If your installation uses third-party libraries, install them.
10Copy the installation to the Secure Agent machine.
11If your installation uses third-party libraries, verify their installation.
Step 1. Enable access to third-party libraries
To use the Python transformation with third-party libraries, the runtime environment must have access to an installation of Python and the resource files that you reference in the Python code.
When you install Python, you can include any third-party libraries you want to access in the Python code.
In the mapping task, use an advanced session property to specify the locations of the Python installation directory and the Python executable:
1In the mapping task advanced session properties, click Add.
2Select advanced.custom.property as the session property name.
3For the session property value, enter the following text:
Before you install Python, make sure that the Secure Agent machine has the required packages.
The following table lists the commands to install a package on the Secure Agent machine:
Package
Command
OpenSSL
sudo yum install openssl-devel
zlib
sudo yum install zlib-devel
libffi
sudo yum install libffi-devel
Step 3. Download the Python distribution
Find the version of Python that you want to install on the Secure Agent machine and extract the files.
1Navigate to the home directory.
2Download the Python distribution onto the Secure Agent machine. For example, you can run the following command to get an installation of Python 3.6.5 from the internet:
This command downloads the Python distribution in the home directory.
3To untar the file, run the following command :
tar -xvf Python-3.6.5.tgz
The extracted files appear in the directory ~/Python-3.6.5.
Step 4. 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 Python3 directory under the home directory, run the following command:
mkdir Python3
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 5. Install Python
Run commands to compile and build the Python installation.
1Navigate to the ~/Python-3.6.5 directory where you extracted the Python distribution:
cd Python-3.6.5
2To compile Python under $workingdir/Python3, run the following command: