Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm trying to take the next step in programming ArcGIS with Python and see if its actually possible to run my script/code without having to load ArcMap and paste them into the Python window. I imagine I would do this view some sort of IDE specific to Python that loads something from ArcGIS.

How would I got about doing this?


Update: Summary of the solution

I went the Eclipse + PyDev route. Here are my notes on installing everything and getting it working:

Download Eclipse

This is slightly confusing given all the different flavors that are available (Java, Java EE, C/C++, etc.). I went with C/C++ since that's what familiar to me. It doesn't really matter since PyDev gets installed after this step. Pick what you want.

Install PyDev

PyDev will be installed via Eclipse. The instructions linked worked perfectly.

Configure PyDev

The above question gives a screenshot of a Windows configuration, while this link from an ESRI blog has more info for Unix systems although it is from 2008.

Ran a test script

Fired up a script I had been working on and it worked. There seems to be some differences in executing code in this way in how to access shapefiles and the workspace, etc, more explicitness is required. More to learn here.

share|improve this question
    
I confess this seems almost more of a Python question and also betrays my ignorance of the Python environment, but hopefully the answer is of use to others who are new to ArcGis + Python! –  mindless.panda Jan 5 '12 at 23:08
    
I think using IDLE would've been easier. PyDev is a bit of an overkill in this situation I think. You might also want to build some models in Model Builder and export them as .py files. That way you'd have a feel for the Python code. –  R.K. Jan 8 '12 at 13:45
    
This is simply repeating what I have said! It is the best though isn't it. The key with using it this way, is that you're able to create Objects and classes which some of the other ways doesn't support. It allows you to really concentrate on building cracking code, deployable on the server. Good luck! –  Hairy Jan 10 '12 at 8:55
2  
Mindless, only one reply here mentions the Eclipse + PyDev solution. Is there a reason you did not vote it up? –  whuber Jan 11 '12 at 13:37
    
None. I accepted the Eclipse suggestion since that's the way I went and preferred. I only answered my own question to document the setup process. Any reason my answer should be edited into the question? Perhaps this should be a CW? –  mindless.panda Jan 11 '12 at 17:25

5 Answers 5

up vote 9 down vote accepted

The best way I have found to use Python, is using Eclipse with PyDev. It's a good IDE for developing with and allows for inline debugging, not commend line debugging, and it has allwoed me to build very professional back end Data Management applications on a large scale.

IDLE is only ever that good for testing scriplets, in my opinion, and isn't good for designing complex object based solutions.

It's also incredibly easy to set up.

share|improve this answer
    
Is there much involved with getting Eclipse + PyDev to work w/ ArcGIS functionality? Other answers seem to indicate some peculiarities with using the non-Arc installed Python? –  mindless.panda Jan 6 '12 at 14:38
    
None at all, simply ensure you have arcgis desktop installed, and set up Eclipse to work with PyDev and you're away. It took 5 mins to set it up and then all you havw to do is reference arcpy in your script. Seriouly, I have not seen an easier, better way to do it. –  Hairy Jan 6 '12 at 15:46

I believe an IDE for python comes with the ArcGIS-10 installation. It is called IDLE, and is a simple but effective tool for interfacing with ArcPy without opening an instance of ArcMap itself. You should be able to find it under the "Python 2.6" directory of your ArcGIS installation on the start menu. Just be sure to import arcpy before performing anything specific to the package! Any script example you see in the ArcPy reference for standalone scripts will work in IDLE's interface.

share|improve this answer

If I understand the question, you want run your scripts standalone, outside of the ArcMap session. Totally do-able. Save your code into a Python file (.py). As far as editing, you can use IDLE or any text editor (even Notepad) for that matter. Sometimes when you are starting out, it's easier to use a text editor so you can focus on learning the code, not the IDE. Make sure you have your PATH environmental variables setup properly, so they include your Python install directory, something like:

C:\Python26\ArcGIS10.0\Lib\site-packages\;C:\Python26\ArcGIS10.0;C:\Python26\ArcGIS10.0\Scripts

Then it's simply a matter of opening up a command prompt (Start > Run > type 'cmd' [without the quotes]) and typing:

python c:\path\to\python\script.py

Now, this assumes you have all of your data paths hardcoded in the script.

That's the basics. There of course is way more, like using input parameters.

share|improve this answer
3  
just a comment regarding IDLE or a standard text editor. I personally find PythonWin a much easier way to work since it has better debugging capabilities - crucial while learning. See instructions on installing PythonWin with ArcGIS 10. You do need to ensure you install the version of PythonWin from the ArcGIS DVD, or it can break the Python installation. –  Stephen Lead Jan 5 '12 at 23:46

When ArcGIS installs it installs its own version of python(ie you don't need to import the dependencies).. be sure to use this one..

I use python CLI as a calculator as well as running saved scripts.

Python as a calculator is great as you can define variables.. I got this tip from the python tutorials http://docs.python.org/

I have a shortcut to the CLI via command prompt on my task bar %windir%\system32\cmd.exe /k "C:\Python26\ArcGIS10.0\python.exe"

I used windows scheduled tasks to do some maintenance via scripts that i exported out of model builder and then hacked in some changes to python built-ins such as applying dates to filenames for backups.

share|improve this answer

I have just started to get to grips with Python and arcpy and I found PyScripter really useful. Its a full-blown Python IDE

share|improve this answer
2  
Best IDE I've used to date is PyScripter and it's free! –  Hornbydd Jan 6 '12 at 15:56
2  
PyScripter is really great. Excellent code completion, syntax highlighting, search & replace, tabs for showing multiple PY scripts. Much more useful than IDLE in my opinion. –  RyanDalton Jan 6 '12 at 19:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.