Question

Configuring Anaconda environment in FME


I am trying to set up my anaconda environments in FME, using the custom interpeter function. As interpeter I selected the .dll file (C:\\(...)\\anaconda2\\envs\\gdal\\python27.dll). This succeeds in recognizing Python and having a basic setup. However, my packages are not included. Trying to import geopandas, which works fine in my Anaconda editor, results in the following error in FME:

Python Exception : No module named geopandas 2018-12-04 12:50:20| 0.5| 0.0|ERROR |Error executing string `importfmeimportfmeobjectsprinthelloPieterimportossys#sys.path.appendrC:UsersfvzfAppDataLocalContinuumanaconda2envsgdalpython.exeimportgeopandasasgpd#fromrasterstatsimportzonal_statsprinthelloPieter#TemplateFunctioninterface:#Whenusingthisfunctionmakesureitsnameissetasthevalueof#theClassorFunctiontoProcessFeaturestransformerparameterdefprocessFeaturefeature:printhelloPieter#TemplateClassInterface:#Whenusingthisclassmakesureitsnameissetasthevalueof#theClassorFunctiontoProcessFeaturestransformerparameterclassFeatureProcessorobject:def__init__self:passdefinputselffeature:self.pyoutputfeaturedefcloseself:pass' 2018-12-04 12:50:20| 0.5| 0.0|FATAL |Factory proxy not initialized 2018-12-04 12:50:20| 0.5| 0.0|FATAL |PythonCaller(PythonFactory): PythonFactory failed to process feature 2018-12-04 12:50:20| 0.5| 0.0|ERROR |A fatal error has occurred. Check the logfile above for details 2018-12-04 12:50:20| 0.5| 0.0|INFORM

What can I do to fix this and import all my packages into FME?


12 replies

Userlevel 4

The path to the dll isn't necessarily what will determine which Python interpreter is actually used. Have you tried setting the PYTHONHOME environment variable? In more recent versions of FME 2018.1 you can set PYTHONHOME in the FME options, in earlier versions you'll have to define it as a system environment variable (and possibly restart your PC for it to take effect).

The path to the dll isn't necessarily what will determine which Python interpreter is actually used. Have you tried setting the PYTHONHOME environment variable? In more recent versions of FME 2018.1 you can set PYTHONHOME in the FME options, in earlier versions you'll have to define it as a system environment variable (and possibly restart your PC for it to take effect).

The PYTHONHOME is available in the FME translation option. I tried setting this to the directory that contains python.exe in my specific Anaconda environment ( C:\\(...)\\anaconda2\\envs\\gdal ). However, this didn't work, not even after restarting. It still appears FME is using its built-in Python with basic packages.

Userlevel 4

I was able to use FME with Anaconda as the Python interpreter using the following setup:

  • FME 2018.1, 64-bit version
  • Anaconda 4.5.11 with Python 3.6, 64-bit version

In FME Options:

In the workspace scripting parameters:

I think the most important aspect is to match up the "bitness" of FME and Anaconda, you cannot use FME 32-bit and Anaconda 64-bit, for example.

I was able to use FME with Anaconda as the Python interpreter using the following setup:

  • FME 2018.1, 64-bit version
  • Anaconda 4.5.11 with Python 3.6, 64-bit version

In FME Options:

In the workspace scripting parameters:

I think the most important aspect is to match up the "bitness" of FME and Anaconda, you cannot use FME 32-bit and Anaconda 64-bit, for example.

Thank you for your help and the screenshots. Running Anaconda2 seems to work well (FME,INFORM|Python version 2.7 loaded successfully). However for some reason I'm still unable to import custom packages (gdal,geopandas,rasterstats) from the FME pythoncaller, resulting in the following error:

ERROR |Python Exception : DLL load failed:

But importing the packages in the same anaconda environment using the anaconda prompt is succesfull

(gdal) C:\\>python Python 2.7.15 |Anaconda, Inc.| (default, Nov 13 2018, 17:33:26) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

>>> import gdal

>>> import geopandas

>>> import rasterstats

>>>

Do you have any idea what might cause this error?

Userlevel 4

Thank you for your help and the screenshots. Running Anaconda2 seems to work well (FME,INFORM|Python version 2.7 loaded successfully). However for some reason I'm still unable to import custom packages (gdal,geopandas,rasterstats) from the FME pythoncaller, resulting in the following error:

ERROR |Python Exception : DLL load failed:

But importing the packages in the same anaconda environment using the anaconda prompt is succesfull

(gdal) C:\>python Python 2.7.15 |Anaconda, Inc.| (default, Nov 13 2018, 17:33:26) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

>>> import gdal

>>> import geopandas

>>> import rasterstats

>>>

Do you have any idea what might cause this error?

You can use a little known trick to invoke the Python prompt using FME, that way you have an interative session where you can inspect PYTHONPATH, versions, etc.

From the command line, go to the directory where FME is installed and type

fme.exe python

Hopefully that should help you locate the issue.

You can use a little known trick to invoke the Python prompt using FME, that way you have an interative session where you can inspect PYTHONPATH, versions, etc.

From the command line, go to the directory where FME is installed and type

fme.exe python

Hopefully that should help you locate the issue.

Yes with your help I found the issue!

For some reason FME Custom Python interpreter only referred to my base Anaconda environment, even with PYTHONPATH and dll in a different environment. Still no idea why.. But worked around by installing necessary packages in my base environment. Not perfect, but it does the job.

Thanks a lot!

Userlevel 4

Yes with your help I found the issue!

For some reason FME Custom Python interpreter only referred to my base Anaconda environment, even with PYTHONPATH and dll in a different environment. Still no idea why.. But worked around by installing necessary packages in my base environment. Not perfect, but it does the job.

Thanks a lot!

Excellent!

Badge

 

I had a similar issue configuring Anaconda with FME, this post helped but missed some details on compatibility. Hopefully this saves someone some time in the future

-The version of FME/Anaconda/Python must all be compatible. I have FME 2018.1 and require features implemented in non 2.7 python, while the current version of Anaconda is python 3.7 (No 2018 fme support). So I had to find an old version of Anaconda that supports a version 3 of python supported by FME. Anaconda3-4.2.0-Windows-x86_64 fills this need with python 3.5. Alternatively updating FME to 2019 would also solve this problem.

-Specify the paths per @david_r post

-If there is a compatibility of python issues FME will revert to it's default installation, ignoring the Anaconda install

-I also don't have local admin but the non-admin local install of Anaconda seems to work just fine (AppData\\Local\\Continuum\\

 

 

Badge +8

This thread is now 4 years old but there isn't a newer one (that I've found so far) the properly addresses the issue. Would someone who knows please update this thread to cover FME v2022? (and/or verify that the info in this thread still applies)

Badge

This thread is now 4 years old but there isn't a newer one (that I've found so far) the properly addresses the issue. Would someone who knows please update this thread to cover FME v2022? (and/or verify that the info in this thread still applies)

I had to update Anaconda for 2022 Fme and the process is the same as this thread. You get a version of anaconda that is compatible with 2022 fme python (python 3.6 - 3.9).​ Install it then set the python interpreter in (fme options- translation) to the location of the anaconda install and the python dll associated with the install (as in the screenshot above).

I am using FME 2023, have the same problem. However, is not clear, how to use a specific environment of Anacoda, not the base(root) one. As I understand @david_r​ uses the root in order to install packages pip install

Userlevel 4

I am using FME 2023, have the same problem. However, is not clear, how to use a specific environment of Anacoda, not the base(root) one. As I understand @david_r​ uses the root in order to install packages pip install

Indeed, but not always... It'd be too simple ;-)

If you really, really need all of Anaconda then it's possible (but sometimes fiddly) to point FME to your Anaconda folders. But if you only rely on a few modules present in Anaconda, it's probably easier to simply install those into FME, either in the user folder or the FME home folder.

Reply