You are here: Working with FME Desktop > Working with FME Server > Importing Custom Python Modules to FME Server

Importing Custom Python Modules to FME Server

If you have a custom python module you need to use on FME Server that is not part of the Python standard library, you must import it to the server. There are two ways to do this:

Add the Python module to the FME Server Python folder

This method requires access to the FME Server installation folder on your server.

  1. Copy the module to the FME Server Python folder:
  2. <FMEServerDir>\Server\fme\python

  3. Use a standard import <module> command in your Python script.

Upload the Python module when publishing the workspace

  1. Add the following lines to the beginning of your script to ensure the module gets imported:
  2. import pyfme

    MF_DIR=pyfme.FME_MacroValues['FME_MF_DIR']

    sys.path.append(MF_DIR)

  3. Publish the workspace to FME Server. Make sure you select the module file as a resource file to upload when publishing.

If your Python script needs to access a file that you cannot manually place on the server, then use the same process:

  1. Add the following to your Python script in order to set the path variable to the folder where the file is uploaded:
  2. import pyfme

    path=pyfme.FME_MacroValues['FME_MF_DIR']

  3. Now you can reference your file as path/file in your python script. For example:
  4. file = "%smyFile.txt"%path

  5. Publish the workspace to FME Server. Make sure you select the file as a resource file to upload when publishing.