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\\
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                                                                                                                 


print dataDir

arcpy.FeatureToLine_management(dataDir+shp, 'temp_links')

What I get back is:

$ /opt/arcgis/server/tools/python ./arcpytest-1.py
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.

  • 2
    Do you maybe NEED the backslash after the drive specification (ie z:\home\... instead of c: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 like os.path.isdir and os.path.isfile to see what exactly is going wrong. Is the username really arcpy-tmp and the files really under /home/arcpy-tmp? Aug 13, 2012 at 18:57
  • Thanks! Wow; it's finicky. Python/arcpy doesn't work if I've connected with ssh -X (rather than ssh). It doesn't work if I use a symbolic link to the python executable. Anyway, yes, the backslash was it; thank you. Now I get: 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 arcpy
    – CPBL
    Aug 14, 2012 at 13:36
  • Oh, and as for the user, no I had to "sudo su arcgis" (which is a pain -- users need sudo access to use arcpy...) and I found that I needed the files to be owned by arcgis, too! So I created a new folder in /home which is owned by arcgis but is universally readable/writeable.
    – CPBL
    Aug 14, 2012 at 20:06
  • In the interest of documenting... sudo 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 that import arcpy doesn't fail.
    – CPBL
    Aug 15, 2012 at 15:12
  • 1
    Could you post your solution as an answer to this question and mark it accepted so other people searching for this in the future could find it? Aug 15, 2012 at 17:29

2 Answers 2


I haven't had too much trouble using arcpy on linux so far.

I installed arcgis into the arc users home (this was the default location, and it was recommended one install as the arc user). As mentioned above in .../arcgis/server/tools you will find a 'python' executable. If you look at that file, you'll see how to run arc's concept of python on linux.

To run arcpy scripts on my RHEL 6 servers this is what I do:

In ~/bin:

ln -s /path/to/myarcpyexecutable arcpython

I found I didn't need much of what was in the original bash script, mine looks like this:

    if [ -f $arcenv ]; then                                                              
       . $arcenv                                                                          
       if [ "x$DISPLAY" = "x" ]; then                                                     
         . $installDir/framework/runtime/xvfb/init_Xvfb.sh                                
         StartXvfb > /dev/null 2>&1                                                       
       wine "C:/Python27/ArcGISx6410.1/python.exe" $*                                     
   echo "Unable to set up environment.  Cannot find $arcenv"                          

Any python script I want to run I put


at the top and then can run it like so:


/home/arc/bin is first on my path, so I just use 'arcpython script.py' to run anything else. You could link 'python' to the arc version of python if you wanted, but I have that running python 2.7, and generally use virtualenvs for all my non-arcpy python stuff.

This is working quite well so far for me. I don't need to use sudo, and most things work as you'd expect (linux paths for example), the main annoyance is that I could never get it to work with ipython.

It is a bit awkward, but nothing compared to having to work on windows!

  • When you say you don't need sudo, is that because you're running under the arc user? We are running on a server, and multiple users want to use arcpy. So if we want to operate under our individual accounts, we need to su arcpy, which requires sudo.
    – CPBL
    Apr 26, 2013 at 0:15

Here is what we've learned so far. I'm not recommending anyone pursue ArcGIS server for Linux if they want to run scripts. It's an amazing kludge, and very awkward. (I get the impression other tools (postGIS, ie modern, database driven computation) might be mature, as well as elegant?)

To run ESRI's python, I have to login without X forwarding.

sudo su arcgis
cd /opt/arcgis/server/tools/ 

To run some code, we have created an arcgis-owned folder to work in, /home/arcpy-tmp, and have to have superuser powers (as above) to do anything. The beginning of an arcpy script can look something like the following. Errors that come up that sound like they're GIS-related are often really just to do with permissions over files/directories (ugh). So make sure that everything you're touching is owned by the system's arcgis user.

import arcpy, urllib, zipfile, os, string
from arcpy import env
raw_path = "Z://home//arcpy-tmp//"           

gdb_path = raw_path+"Working.gdb"
env.workspace = gdb_path

Because you cannot import arcpy in any python subprocess, I've also arranged to parameterise what my analysis functions do (ie the my_analysis_code.py module takes an argument, which is, for instance, a shapefile to analyse), and then to call them from another (real/normal/native python?) script,

os.system('/opt/arcgis/server/tools/python  my_analysis_code.py  '+shpfilename)

This way, you can use as many processors as you want.

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.