arcpy.Exists() return False even if feature class exists when used inside FME

1955
8
Jump to solution
07-04-2017 05:50 AM
MaximeDemers
Occasional Contributor III

Something very strange happen in my FME shutdown python script that uses arcpy.Exists() function. This function test if a feature class exists or not and returns True or False.

The following script returns False in FME even if the feature class do exists. I have tryed the same script in a python shell using the same python interpretor, and it returns True.

Any ideas why it fails in FME shutdown python?

  1. import arcpy
  2. print arcpy.Exists("\\\\cnatrtd8\\geo\\GEODEV011.sde\\GEO09_WEB_MERCATOR\\GEO09E03_CS_STA")
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MaximeDemers
Occasional Contributor III

Yes, it was a known problem of FME 2016 with PYTHONPATH environment variable and arcpy. The  workaround is the following:

  1. # Fix pythonpath
  2. import sys
  3. sys.path.append(sys.path.pop(0))
  4. sys.path.append(sys.path.pop(0))
  5.  
  6. # Business as usual from here
  7. import arcpy
  8. arcpy.env.workspace = r"\\cnatrtd8\geo\GEODEV011.sde"
  9. print arcpy.Exists(r"GEO09_WEB_MERCATOR\GEO09E03_CS_STA")

Note that the issue is resolved in FME 2017

View solution in original post

8 Replies
JoshuaBixby
MVP Esteemed Contributor

Seeing you are using an SDE connection file, what are the properties in the file?  Is it setup for DB user authentication or Operating System authentication?  If the latter, does the account or service running FME server have credentials to access the geodatabase?

0 Kudos
MaximeDemers
Occasional Contributor III

Hi!

How can I know if the DB use user authentication or Operating System authentication?

I have forgot to mention that FME is not running on a server,  but on the same desktop than the python shell, and both are using the same python interpretor (I have double check using sys.version to be sure its the same python interpretor).

0 Kudos
MaximeDemers
Occasional Contributor III

I have look in the Database Connection properties of the .sde connection file and I can confirm the Authentication Type is: Database authentication, and the username and password are saved inside

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

FME and ArcMap may be on the same machine, and even using the same Python interpreter, but it doesn't mean they are executing under the same credentials when accessing the geodatabase.

In terms of determining authentication type; launch ArcCatalog, locate the SDE connection file, and right-click properties:

MaximeDemers
Occasional Contributor III

I can confirm the Authentication Type is: Database authentication, and the credentials are saved inside the .sde. I doubt that this is the cause of the problem...

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

It might be time to head over to forum - FME Knowledge Center , and see what the folks there have to say.

AllisonBailey
New Contributor III

hmmm... I just had a very similar result, but it was simply with  table inside a personal geodatabase.   Did you find a solution?

0 Kudos
MaximeDemers
Occasional Contributor III

Yes, it was a known problem of FME 2016 with PYTHONPATH environment variable and arcpy. The  workaround is the following:

  1. # Fix pythonpath
  2. import sys
  3. sys.path.append(sys.path.pop(0))
  4. sys.path.append(sys.path.pop(0))
  5.  
  6. # Business as usual from here
  7. import arcpy
  8. arcpy.env.workspace = r"\\cnatrtd8\geo\GEODEV011.sde"
  9. print arcpy.Exists(r"GEO09_WEB_MERCATOR\GEO09E03_CS_STA")

Note that the issue is resolved in FME 2017

View solution in original post