Problem when using python/arcpy script in FME

2097
4
04-04-2017 04:57 AM
FlavieMORAUX1
Occasional Contributor

Hy,

encounter a problem when using a python / arcpy script in FME, from a PythonCaller.

Some arcpy instruction does not work in FME, for example :

  • arcpy.Exists ==> return feature class does not exist ;
  • arcpy.CopyFeatures_management ==> fails with following explanation feature class does not exist.

However, in ArcGIS Desktop it works (feature class exist) :

Arcpy in ArcGIS Desktop works.

However, in python it works (feature class exist) :

Arcpy in Python.

Here is the code contained in FME :

# Import system library

import sys

reload(sys)

sys.setdefaultencoding('utf-8')

 

# Import arcpy librairy for FME

agdArcpyPath = r'C:\Program Files (x86)\ArcGIS\Desktop10.3\arcpy'

agdBinPath=r'C:\Program Files (x86)\ArcGIS\Desktop10.3\bin'

if agdBinPathnot in sys.path:

    sys.path.append(agdBinPath)

if agdArcpyPath not in sys.path:

    sys.path.append(agdArcpyPath )

import arcpy

# Workflow 

fcPath= r"\\infogeo.ressources.paris.mdp\Parametres\ADMIN_SDE_AGS\00_CONNEXIONS_PROPRIETAIRES\BOSSINTG\BOSS_Intg@DVD_PVP(GISOwner).sde\DVD_PVP.CELARB_POINT"

if arcpy.Exists(fcPath): # Problem, it return False in FME

   # Execute workflow

   pass

#end if

For information here is the technical background :

  • ArcGIS Desktop 10.3.1 French
  • FME 2016.1

Has anyone ever succeeded in integrating some python/arcpy code into FME?

Do you have an idea to solve my problem?

Thank you for your help.

Flavie

0 Kudos
4 Replies
BruceHarold
Esri Regular Contributor

Bonjour Flavie

It might be arcpy is not loading properly.

Please see how I call arcpy in this example:

http://www.arcgis.com/home/item.html?id=7e51a30ca0e54988b073e5d589e4441b 

Making a subprocess ensures the Python environments are clean.

Regards

0 Kudos
FlavieMORAUX1
Occasional Contributor

Hy Bruce,

Small problem... ZIP file contains only toolbox (no python file) and in ArcMAP (10.2.2) toolbox appears as empty.

ShutdownScript
Regards,

Flavie

0 Kudos
BruceHarold
Esri Regular Contributor

Hi Flavie

You need Data Interoperability extension installed and enabled, then you will see a Spatial ETL tool, in the advanced parameters is a Python shutdown script.  My apologies for not explaining, it was an early start :-).

FlavieMORAUX1
Occasional Contributor

Hy Bruce,

Sorry for the late response, I had to interrupt my project for another.

Thanks for your sample toolbox. Like this I discovered DataInteroperability extension.

But that does not solve my problem, you does not call arcpy library in PythonCaller component.

PythonCaller

So I used SystemCaller instead of PythonCaller.

Methodology is different, but it also acceptable for my project.

Thanks again,

Flavie

0 Kudos