I am a beginner and just starting to learn how to use Python I learned from Python Scripting for Map Automation.
My question to you is that whenever I get an error I see the word Traceback or errors in highlight red in my python window.
My question to you is do I need to have a pythonWin installed ? My computer at work does not have it but I use the python Window inside ArcMap.
Are there site that can I read or learn about the Traceback error ? I am sure there are bunch of question that Traceback has in it.
So what does Traceback means and what does it do ?
Thanks
yes Arcmap 10.2 is 32 bit as well
Change of scernico, I am at home and have ArcGIS 10.1 and got to download Pyscripter and did some research on Pyscripter and how it works and so on.
I found really good info about it here : Advanced Geographic Research: Software This article explains how to set it up and run with Pyscripter.
Now I have something in my mind is Can I have ArcMap open while Pyscirpter open at the same time ?
Yes...I do it all the time. If everything is installed properly, you should be able to use
You just need to remember to use
import arcpy
before you try to use any arcpy functions
Hi Dan,
I am starting to work on using Pyscripter and I am learning how to use. Now the thing I have a trouble writing code I am using replaceWorkspace. That code requires four parameters however when I write the code there is no pull up list to select and click to choose from. Is something wrong with the Pyscripter I need to fix the problem ?
Just remember the suggestion by Francisco Girón Gesteira (Re: Python error question )
If you are able to install Pyscripter set up the options to read arcpy help and perform code completion with it. Just add arcpy to the special packages line under code completion in IDE options
This provides help during the edition of code.
What you need to bare in mind is that PyScripter is not the same as the Python window in ArcMap. The Python window is aware of the layers available in the TOC of ArcMap. PyScripter is not. You will have to write them yourself (you won't be able to select them from a list of options). What I normally do is have the online Help open and check the syntax and example: ArcGIS Help (10.2, 10.2.1, and 10.2.2)
See the error
>>> mxd.replaceWorkspaces(path + r"\City_of_Westerville.mdb", "ACCESS_WORKSPACE", path + r"\Westerville.gdb", "FILEGDB_WORKSPACE")
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
NameError: name 'mxd' is not defined
So the Pyscripter doesnt understand so I have to manually change the mxd to something else like ?
The point is that creating the mxd object inside the Python window can be done using the "CURRENT" keyword. In a standalone environment (as is PyScripter) you cannot use that keyword. You will have to specify the path to the mxd document. Please read: ArcGIS Help (10.2, 10.2.1, and 10.2.2)
I am trying to understand between the two Pyscripter and Python Window and how it works together.
So for the Pyscripter you just write to test it and if it works you copy and paste them to the Python Window but change to the functions or classes to Python window where they understand it and run from Python windows?
Or do I just write the code within the Pyscripter and run the code from there and will that change in ArcMap ?
Thanks
Sometimes I use the python window to do something quick and dirty. You can also try things in the Python windows and copy and paste it into the editor of PyScripter to create something more enhanced. I do prefer coding directly in PyScripter since it is much easier to change things on lines written before, while in the Python window you write a single line, execute it and code the next line. I also execute the code directly from PyScripter (as do most people).
The other advantage of coding in and IDE like PyScripter is that your syntax is directly checked and you easily save what you are writing. When you create a script in PyScripter you can easily change hard coded variables into parameters and create a toolbox script that you can run in ArcMap and share with others. The other people don't need any coding experience, since they see a tool just like the ones provided by Esri.