What is a Python Interpreter?
An interpreter is another name for a Python installation. FME installs its own Python interpreter, but you may wish to use a different one.
Why would I want to choose a different Python Interpreter?
There are various reasons you might choose a different Python interpreter:
-
When creating a Python script for use with both FME and ArcGIS (for example) you could point FME to use the Python Interpreter installed by ArcGIS, to ensure both applications work.
-
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 to that which FME installs, you will need to install that version separately and direct FME to use it. For example, FME (currently) uses Python v2.7. Integrating FME with 3rd-party Python modules that only work under Python v2.6 would require the installation and use of a v2.6 interpreter.
Installing Python for FME
For reasons outlined below, when installing a different version of Python we recommend you use the option "Install just for me" and not "Install for all users".
Also note that you will not be able to use 64-bit Python through a 32-bit version of FME, or vice versa.
Selecting a Python Interpreter with FME 2012
To choose a different Python interpreter for FME requires you to select that Interpreter's DLL file. In FME 2012 the procedure is as follows:
-
Select Tools > FME Options from the menubar.
-
Select the tab for "Runtime".
-
Check the box labelled "Use Custom Python Interpreter"
-
Select the location of the Python DLL you wish to use
NB: Be aware that this option controls FME as a whole, and not just the current workspace. Therefore all FME processes will use this alternative version of Python, until you revert this option.
Selecting a Python Interpreter for FME Server / FME Engine 2012
FME Engine has a command line interface that can be used instead of the the Workbench FME Options. To change the Python interpreter open a command window and run the following commands:
fme APPLY_SETTINGS "Python/Use Custom Python" true
fme APPLY_SETTINGS "Python/Python Interpreter" <pythonpath>
where <pythonpath> is replaced with the complete path to the desired Python DLL. This should be done on each computer running an FME Engine. The setting can be disabled by running:
fme APPLY_SETTINGS "Python/Use Custom Python" false
NOTE: There is currently an issue in FME Server 2012. Please contact Safe Software Support if you wish to use a Custom Python Interpreter with FME Server 2012.
Selecting a Python Interpreter with FME 2011 or earlier
FME version 2011 (and earlier) did not have the Python Interpreter option. Therefore the procedure is more complex.
Either:
-
In the Edit Header dialog of FME Workbench, add the line 'FME_PYTHON_VERSION 2.x' (where x is between 3 and 7 inclusive).
Or:
-
Set the environment variable FME_PYTHON_VERSION to 2.x (where x is between 3 and 7 inclusive).
Known Issues
In doing this for 2011, there are known concerns or issues:
-
When these methods are used, FME will overlook its own built-in interpreter, even if the versions match
-
These methods will work in FME2012, but will be overridden by the Python Interpreter option (if set)
-
FME will choose the first Python interpreter in the PATH environment variable that matches the specified version, so selecting a specific interpreter (for example the ArcGIS one) requires that to have priority
-
Be aware that installing another product that includes Python could change the PATH setting and break your configuration
Where do I find the Python DLL?
It depends on how you installed Python, and what your OS is.
If you installed 32-bit Python "for all users" on a 32-bit computer, it will be in c:\Windows\System32
If you installed 32-bit Python "for all users" on a 64-bit computer, it will be in c:\Windows\SysWOW64
If you installed 64-bit Python "for all users" on a 64-bit computer, it will be in c:\Windows\System32 (I know, me neither).
If you installed Python "just for me", it will be in the Python installation folder, for example c:\Python26
Are there any problems 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.