Monday, October 21, 2013

PyScripter for ArcGIS 10.2

This tutorial is for my GEOG 490 students. I hope others find use in it too.


PyScripter is another Python GUI (Graphical User Interface) similar to the ones we've been using in class (IDLE and PythonWin). PyScripter has several advantages over these other programs, mainly the ability to auto-complete ArcPy, which really speeds things up.


Installing PyScripter

It's important to start out with a clean install of Python. I tried to install PyScripter with multiple versions of Python on my office computer and the result was a frustrating hour trying (and failing) to get PyScripter to talk to ArcPy. If you need multiple versions of Python, I wish you luck. Please let me know if there's a secret I missed.

If you have only installed ArcGIS 10.2 (Python 2.7.3 comes as part of that installation) you can skip the first step.

  1. Uninstall all versions of Python from your computer. You will then need to repair your ArcGIS 10.2 installation to reinstall the ArcGIS-flavored Python.
  2. Download PyScripter (http://code.google.com/p/pyscripter/http://sourceforge.net/projects/pyscripter/
    1. Either version (32-bit or 64-bit) should work on most machines. If you're unsure which version you need, go with the x86 version.
    2. There is a stand alone version of PyScripter that you can install on a flash drive or external hard drive. To get that version talking to ArcPy visit Map Guy Mike's tutorial
  3. After the install check the Python paths for ArcPy
    1. Navigate to c:\python27\Lib\site-packages
    2. Find the Desktop10.2.pth file-you'll need to view/edit this file with Notepad
    3. This file should contain the right information, feel free to skip this step and come back to it if ArcPy doesn't work.
    4. There should be three line in the file:
      c:\Program Files\ArcGIS\Desktop10.2\arcpy
      c:\Program Files\ArcGIS\Desktop10.2\bin
      c:\Program Files\ArcGIS\Desktop10.2\ArcToolbox\Scripts
    5. If you need to, add these lines, save and close the file. If these lines are in there, you are good to go.
  4.  Fire up PyScripter (in the Start menu, choose PyScripter (Latest Python Version))

PyScripter Setup

Only one small thing to do here...Go to the Tools menu, then Options > IDE Options. Under special packages add arcpy to the end of the list.


Test it out

In the bottom Interpreter (command line) window try import arcpy  hit enter (maybe twice) and see if it works.

A Quick Tour

The upper window in PyScripter is the Editor window-this is where you will write your stand alone code. The auto-complete works in here as long as you have your module import statements at the top (which you should anyway).
** As a bonus, you don't have to save your scripts before you run them. BUT, be sure that you do save them at some point.

The bottom window is the Interpreter (command line) window. This is like the main IDLE window, where you can test individual code bits and where some messages will appear.

Along the bottom are some tabs for advanced code editing and debugging. One of my favorites is the Variables tab. This is where you can see what variables are in memory and what their values are. This will be important as we start to build larger scripts and need to start debugging them.


.

3 comments:

  1. dimeapp.in is one of the fastest Live cricket score app performing in the arena of Cricket match scores and You can choose any upcoming match of your choice to watch it over and get full insights over Match history.
    dimeapp.in is an Ads free cricket app which makes your cricket viewing experience even more exciting plus Accurate match odds with session updates, Search matches date-wise, team-wise, and series-wise too.
    dimeapp.in is 100% free to download and use an app for viewing All T20, ODI, Domestic and International women/men Test Matches and even IPLs and PSL. You can even watch the World Cup, Asia Cup and upcoming schedules of upcoming matches in this App.
    dimeapp.in is the No.1 rating app on our list. This app is a lifeline for cricket lovers. Not only, it is interactive & convenient-to-use software, but it furthermore wraps all aspects of cricket.
    It will give to the detailed stats, rankings & records, Precise odd-even sessions. Even it also helps to skillfully navigate team/date/year wise matches. It also provides daily articles & alerts on feverish cricket headlines.
    As per reviews and information on the Internet, we will recommend dimeapp.in for a cricket lover to satisfy their craving to know the scores fastest of fast that too with free-subscription & Ads-free...

    ReplyDelete