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.
- Copy the module to the FME Server Python folder:
- Use a standard import <module> command in your Python script.
<FMEServerDir>\Server\fme\python
Upload the Python module when publishing the workspace
- Add the following lines to the beginning of your script to ensure the module gets imported:
- Publish the workspace to FME Server. Make sure you select the module file as a resource file to upload when publishing.
import pyfme
MF_DIR=pyfme.FME_MacroValues['FME_MF_DIR']
sys.path.append(MF_DIR)
If your Python script needs to access a file that you cannot manually place on the server, then use the same process:
- Add the following to your Python script in order to set the path variable to the folder where the file is uploaded:
- Now you can reference your file as path/file in your python script. For example:
- Publish the workspace to FME Server. Make sure you select the file as a resource file to upload when publishing.
import pyfme
path=pyfme.FME_MacroValues['FME_MF_DIR']
file = "%smyFile.txt"%path