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
- macOS: ./fme python -m pip install <package_name>
<package_name> is the name of the Python package to install.
Default Install Locations
By default, the above commands install to the following location:
- Windows: C:\Users\<user>\Documents\FME\Plugins\Python\python<version>
- 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
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.
- 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