Skip to main content

Hi

Any idea of the best method for using the Arcpy library without changing the interpreter to ESRI?

Thanks

Hi

Why can't you change the Python interpreter? It's pretty trivial.

David


I will probably have to roll out a workbench to FME Server and even though its a small change to a file config, it will be a huge change process here so its easier if i can call it externally to ESRI's interpreter as FME Server is setup to look at the default interpreter.


It is theoretically possible, but the Python interpreter defined in FME Server needs to be identical to the one used by ArcGIS, if not there's a very good chance it won't work at all.

The trick is to set the PythonPath exactly like the one used by the ArcGIS Python interpreter. To find these paths, open the ArcGIS Python interpreter and type:

import sys
for x in sys.path:
    print x

This will dump all the entries in the PythonPath used by ArcGIS, and you can copy those into the non-ArcGIS Python interpreter before loading the arcpy module. Here are the values from my installation, you will have to use your own paths, of course:

import sys
sys.path= ]
sys.path.append(r'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\ArcGIS\Python 2.7')
sys.path.append(r'C:\Python27\ArcGISx6410.2\DLLs')
sys.path.append(r'C:\Python27\ArcGISx6410.2\lib')
sys.path.append(r'C:\Python27\ArcGISx6410.2\lib\plat-win')
sys.path.append(r'C:\Python27\ArcGISx6410.2\lib\lib-tk')
sys.path.append(r'C:\Python27\ArcGISx6410.2')
sys.path.append(r'C:\Python27\ArcGISx6410.2\lib\site-packages')
sys.path.append(r'C:\Program Files (x86)\ArcGIS\Desktop10.2\bin64')
sys.path.append(r'C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy')
sys.path.append(r'C:\Program Files (x86)\ArcGIS\Desktop10.2\ArcToolbox\Scripts')
import arcpy

Let us know how it works for you.

David


cheers, thats spot on!


It is theoretically possible, but the Python interpreter defined in FME Server needs to be identical to the one used by ArcGIS, if not there's a very good chance it won't work at all.

The trick is to set the PythonPath exactly like the one used by the ArcGIS Python interpreter. To find these paths, open the ArcGIS Python interpreter and type:

import sys
for x in sys.path:
    print x

This will dump all the entries in the PythonPath used by ArcGIS, and you can copy those into the non-ArcGIS Python interpreter before loading the arcpy module. Here are the values from my installation, you will have to use your own paths, of course:

import sys
sys.path= ]
sys.path.append(r'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\ArcGIS\Python 2.7')
sys.path.append(r'C:\Python27\ArcGISx6410.2\DLLs')
sys.path.append(r'C:\Python27\ArcGISx6410.2\lib')
sys.path.append(r'C:\Python27\ArcGISx6410.2\lib\plat-win')
sys.path.append(r'C:\Python27\ArcGISx6410.2\lib\lib-tk')
sys.path.append(r'C:\Python27\ArcGISx6410.2')
sys.path.append(r'C:\Python27\ArcGISx6410.2\lib\site-packages')
sys.path.append(r'C:\Program Files (x86)\ArcGIS\Desktop10.2\bin64')
sys.path.append(r'C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy')
sys.path.append(r'C:\Program Files (x86)\ArcGIS\Desktop10.2\ArcToolbox\Scripts')
import arcpy

Let us know how it works for you.

David

sys.env is incorrect; it should be sys.path

 


sys.env is incorrect; it should be sys.path

 

Yes, you're absolutely right, thanks for pointing it out. Fixed.

 

 


Reply