0

I'm trying to call both ArcPy and FME Objects modules in my Python script. I feel like the issue's from sys.path.append()...

import sys
import os

sys.path.append(r"C:\Program Files (x86)\Esri\Data Interoperability (x86)\fmeobjects\python36")

import fmeobjects
import arcpy

I get this error :

Traceback (most recent call last):
  File "H:\etu\buro_MM2\Python_FME\sde2postgis.py", line 8, in <module>
    import fmeobjects
ImportError: DLL load failed: %1 is not a valid Win32 application.

Maybe, this is not the right way to do it. Do you have any idea how to call both modules in my python script ?

0

2 Answers 2

2

I resolved my issue:

  • First I switched the FME Python version to Esri ArcGIS Python 3.6+
  • Then I added this to my python script for the imports :
import sys; d = r"C:\ctibo\du\FME\fmeobjects\python37"; sys.path.append(d)

import os; d = r"C:\Program Files\ArcGIS\Pro\bin"; os.environ["PATH"] = r"{};{}".format(d, os.environ["PATH"])
import sys; d = r"C:\Program Files\ArcGIS\Pro\bin"; sys.path.append(d)
import sys; d = r"C:\Program Files\ArcGIS\Pro\Resources\ArcPy"; sys.path.append(d)
import sys; d = r"C:\Program Files\ArcGIS\Pro\Resources\ArcToolbox\Scripts"; sys.path.append(d)
import sys; d = r"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages"; sys.path.append(d)
import os; e = "FOR_DISABLE_CONSOLE_CTRL_HANDLER"; os.environ[e] = '1' if (not e in os.environ) else ""

import arcpy
import fmeobjects

Now, it works well!

0

Make sure you have ArcMap and ArcGIS Pro installed on same machine as FME desktop and configure your Python Compatibility to use the Esri installed Python 2.7 or Python 3.x (never tested with ArcGIS Pro myself).

Also, if you are using an FME Desktop 64-Bit version you will need to have installed the ArcGIS Desktop Background Geoprocessing (64bit) this will give you access to ArcPy 64-Bit to align with FME 64-Bit version.

On log file you would see something like this below.

2022-04-05 16:22:23|   0.4|  0.0|INFORM|Using Python interpreter from `C:\WINDOWS\SYSTEM32\python27.dll' with PYTHONHOME `C:\Python27\ArcGISx6410.5'

enter image description here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.