We installed ArcGIS SERVER (not Desktop!) 10.1 on a RHEL (Red Hat) machine. ArcGIS Sever is supported for Linux.
However, it appears they don't make it easy to script in python, from the command line, making use of the arcpy module.
There are many things awkward about this. The arcpy library that they use is actually for Windows, with some external patching. In fact, it comes with its own implementation of python. So pathnames look a little weird. You have to be the arcgis user to even get access to python or arcpy. So here is how my code looks:
import arcpy
"""
From http://resources.arcgis.com/en/help/main/10.1/index.html#//0155000005mm000000
The Python libraries installed by an ArcGIS Linux Server installation is Windows 64-bit Python. Therefor, stand-alone Python scripts should always use the Win\
dows path separator (\) when accessing data and other Python modules. Also, be aware that there is a Z:\ which is mapped to the Linux systems' /. Within a Pyt\
hon script you can access data and other Python modules using Z:\ mapping. For example, data in /myuser/myproject/data can be accessed as z:\myuser\myproject\\
data.
This does not apply to Python scripts you publish from ArcGIS for Desktop because the publishing process converts all paths to the correct format.
"""
"""
I'm using:
sudo su arcgis
/opt/arcgis/server/tools/python ./arcpytest.py
"""
dataDir=r"z:home\arcpy-tmp"+"\\"
print dataDir
shp='tgr39105lkA.shp'
arcpy.FeatureToLine_management(dataDir+shp, 'temp_links')
What I get back is:
$ /opt/arcgis/server/tools/python ./arcpytest-1.py
z:home\arcpy-tmp\
Traceback (most recent call last):
File "./arcpytest-1.py", line 28, in <module>
arcpy.FeatureToLine_management(dataDir+shp, 'temp_links')
File "C:\Program Files\ArcGIS\Server\arcpy\arcpy\management.py", line 2343, in FeatureToLine
raise e
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Features: Dataset z:home\arcpy-tmp\tgr39105lkA.shp does not exist or is not supported
Failed to execute (FeatureToLine).
Has anyone tried to use arcpy in this direct way? It's a REALLY powerful server, so we put ArcGIS server on it, but want to use ArcPy for programming.
z:\home\...
instead ofc:home
)? I see you're running it as the right user, but you might want to double check that the perms to your files aren't set to 0 anyway. I'd open an interactive Python session (/opt/arcgis/server/tools/python
) and play around with the interactive prompt with snippets of your code and things likeos.path.isdir
andos.path.isfile
to see what exactly is going wrong. Is the username reallyarcpy-tmp
and the files really under/home/arcpy-tmp
?Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Program Files\ArcGIS\Server\arcpy\arcpy\management.py", line 2343, in FeatureToLine raise e arcgisscripting.ExecuteError: ERROR 999999: Error executing function. Invalid Topology [Feature not found on delete.] Failed to execute (FeatureToLine).
though this worked with Desktop arcpysudo su arcgis
,cd /opt/arcgis/server/tools/
(where my arcgis server 10.1 install is), then./python
works to run python in such a way thatimport arcpy
doesn't fail.