FME Form: 2024.1

Installing Python Packages to FME Form

There may be times when a Python script may require the use of Python packages not included with FME. Because FME ships the pip package management system with its Python interpreter, it is possible to install these Python packages for use in FME using pip.

Invoking pip to Install a Python Package

Run the following command:

  • Windows: fme.exe python -m pip install <package_name>
  • Linux: ./fme python -m pip install <package_name> --system
  • Note  Depending on Linux distribution, --system may either be required or must be excluded.
  • macOS: ./fme python -m pip install <package_name>

<package_name> is the name of the Python package to install.

Note  When running the pip command, there may be a warning regarding the pip version. This warning can be ignored.

Default Install Locations

By default, the above commands install to the following location:

  • Windows: C:\Users\<user>\Documents\FME\Plugins\Python\python<version>
  • Note  Substitute <user> with the Windows user name.
  • Linux: ~/.fme/Plugins/Python/python<version>
  • macOS: ~/Library/Application\ Support/FME/Plugins/Python/python<version>

<version> is the major and minor numbers of the Python interpreter version used by FME; for example, 312 for Python 3.12. To check the Python interpreter version used by FME, run the command:

  • Windows: fme.exe python --version
  • Linux: ./fme python --version
  • macOS: ./fme python --version
Note  To change the Python interpreter used by FME to install Python packages, set the Preferred Python Interpreter option.

The Python interpreter loaded by FME has the version-matching location added to its Python path, so that all modules within that location can be found. For example on Windows, when FME loads a Python 3.12 interpreter, FME adds the following path to the interpreter’s Python path:

C:\Users\<user>\Documents\FME\Plugins\Python\python312

Changing the Default Install Location (Advanced)

There may be rare situations in which you want to install a Python package to a location other than the default.

To specify a location, use the --target argument, as follows:

  • Windows: fme.exe python -m pip install <package_name> --target <package_destination_folder>
  • Linux: ./fme python -m pip install <package_name> --system --target <package_destination_folder>
  • macOS: ./fme python -m pip install <package_name> --target <package_destination_folder>

<package_destination_folder> is the folder in which to install the Python package.

For example, when installing a universal Python package, you may want to make it available for all possible Python interpreters used by FME.

Note  There are two types of Python packages:
  • Universal packages that only contain .py files that work with different versions of Python.
  • Non-universal packages that contain files that are tied to specific versions of Python. Generally these packages contain binaries such as .pyd or .dll files.

To make a universal Python package available for all possible interpreters, set <package_destination_folder> as follows:

  • Windows: C:\Users\<user>\Documents\FME\Plugins\Python
  • Linux: ~/.fme/Plugins/Python
  • macOS: ~/Library/Application\ Support/FME/Plugins/Python
Note  This path is added for all Python interpreters loaded by FME.