Files
-
- 758 Bytes
- Download
If you wish to use ArcGIS arcpy in FME, do not follow the instructions in this article and use the instructions from No Module Named ArcPy: Importing Esri's ArcPy for Use with FME article instead. More information can be found in the subsection titled Using ArcGIS's Interpreter in the Why Choose to Use a Different Python Interpreter section of this article.
What is a Python Interpreter
An interpreter is a library that enables you to run Python scripts. This may also be referred to as a Python installation. FME on Windows and macOS comes bundled with its own Python interpreter for the latest supported Python version. FME Form on Linux uses the system Python interpreter (e.g., Ubuntu’s 20.04’s 3.8 interpreter).
Why Choose to Use a Different Python Interpreter
On Windows, it is possible to use a different interpreter than the one shipped with FME, as long as it is supported by the FME version in use. For example, FME 2024.x for Windows supports Python 3.8-3.12.
There are various reasons you might choose a different Python interpreter.
- When you want to integrate FME with a 3rd-party Python package, installing them with an independent Python Interpreter ensures you won't have to reinstall those packages if you upgrade your version of FME
- When you need to run a script in a different version of Python than the one FME installs, you will need to install that version separately and direct FME to use it. For example, FME 2024.x on Windows includes a Python 3.12 interpreter. Integrating FME with 3rd-party Python modules that only work with Python 3.6 would require installing and using a 3.6 interpreter.
Different Python versions will be supported depending on the FME version. Check to see which version is supported by going to the version-specific page for Python Compatibility documentation or by opening a workspace in Workbench and checking the Python Compatibility parameter (Navigator pane > Workspace Parameters > Scripting > Python Compatibility).
Using ArcGIS's Interpreter
When creating a Python script for use with both FME and ArcGIS arcpy, you should point FME to use the Python Interpreter installed by ArcGIS to ensure both applications work.
If you wish to use the interpreter installed with ArcGIS Desktop or ArcPro, check whether FME and the ArcGIS version installed are compatible. If they are compatible, follow the instructions in this article and ensure the workspace’s Python Compatibility setting is set to the appropriate ArcGIS option.
Installing Python for Use with FME
If you are installing Python for use with FME Flow, choose the "Install for all users" option in the Python installer; otherwise, we recommend using the "Install just for me" option.
Setting a Custom Python Interpreter for FME Form
FME Form on Windows
To choose a different Python interpreter for FME, select that interpreter's DLL file.
In FME Form, select Tools > FME Options from the menu bar.
In the FME Options dialog, select the tab for “Translation", and navigate to the Preferred Python Interpreter setting under the Python Interpreter section. Click on the drop-down and select “Use Custom Interpreter…”.
Enter the location of the Python DLL you wish to use. If you are having trouble determining the location of the python. dll, please see the section titled Where to Find the Python DLL below.
You can also set PYTHONHOME using the Python Home field. It may be necessary to set this for users with multiple Python installations, so the interpreter knows which set of standard libraries to use. More information on the PYTHONHOME environment variable can be found here.
NOTE: This option controls FME as a whole, and not just the current workspace. Therefore, all FME workspaces that have a Python Compatibility value that is compatible with the specified interpreter will use this alternative version of Python until you revert this option.
Setting a Custom Python Interpreter for FME Flow
FME Flow on Windows
To change the Python interpreter on FME Flow on Windows, please see the FME Flow Administrator's Guide on how to configure the Python interpreter.
Where to Find the Python DLL
The name of the DLL will always be "python<majorVersion><minorVersion>.dll" (eg. python39.dll or python27.dll). The location of the Python DLL depends on how you installed Python and on the version you installed.
Python 3.x
Since the installation location can be customized in Python 3.x, the DLL path varies. The default install location is:
C:\Users\<user>\AppData\Local\Programs\Python\Python<majorVersion><minorVersion> where <user> is the user account name and <majorVersion> and <minorVersion> refer to the major and minor versions of the Python installed.
If the DLL is not located in the above path, you can run the following script in the Python console. As the python3x.dll, along with python.exe, are located in the root Python installation folder. The DLL should be located in the returned path.
import sys,os
exePath = sys.executable
print(os.path.split(exePath)[0])Python 2.7
Note: Python 2.7 has been deprecated for FME 2022 and newer. For more information, please see this article on Python 2.7 deprecation.
| Windows bit architecture | Python Installation Type | Installed Python | Path to DLL |
| 32-bit | For all user | 32-bit Python 2.7 | C:\Windows\System32 |
| 64-bit | For all users | 32-bit Python 2.7 | C:\Windows\SysWOW64 |
| 64-bit | For all users | 64-bit Python 2.7 | C:\Windows\System32 |
| 32-bit & 64-bit | Just for me | 32-bit & 64-bit Python 2.7 | C:\Python27 |
Potential Issues With Changing the Python Interpreter
- The ArcGIS 10 Desktop installer also puts its Python DLL into the windows folder, therefore if you install a different version of Python with "for all users", you may inadvertently overwrite this part of the ArcGIS installation.
- If you choose to install Python using the option "Install just for me" then FME Flow will not be able to use this Python interpreter unless you were logged in as the user who is running the FME Server Service.