I am new to ArcGIS Pro, very different from ArcMap. I 've been playing around and trying to get use the new environment. I decided to try a toolbox script that worked in ArcMap (I only installed Pro 2.0.1 i did not add any modules, environments or anything) and I get the following error.
Traceback (most recent call last):
File "D:\GIS Folder\Python Scripts\ZoomToParcel.py", line 11, in <module>
mxd = arcpy.mapping.MapDocument("CURRENT")
AttributeError: module 'arcpy' has no attribute 'mapping'
Failed to execute (ZoomToParcel).
I googled ArcGIS Pro & Python, my apologies I am very confused in some threads i read i need to install python 3.5 and in some indicate that i don't need to.Some threads say i need to add new environments and say i don't need to. I come from ArcMap 10.4.1, I use ArcMap python window and python 2.7.10 IDLE shell. I would like to do the same with Pro. Again i am confused and would like simple instructions on how to get ArcPro python and IDLE Shell working in Pro. I would appreciate any and all the help i can get.
Solved! Go to Solution.
Good luck... ps, check my blog, I have mounds of drivel there associated with python, numpy, scipy, python IDE's, the new 'arcgis' module and Jupyter notebooks. If you didn't get past 'pip' install, don't worry, just bookmark the blog, it is either there or will be.
PS
I also 'pip' installed pythonwin for the oldschool programming experience (with code folding) and Jupyter (QT console) as other IDE's. Search this site for those that use others like pycharm etc
Good luck... ps, check my blog, I have mounds of drivel there associated with python, numpy, scipy, python IDE's, the new 'arcgis' module and Jupyter notebooks. If you didn't get past 'pip' install, don't worry, just bookmark the blog, it is either there or will be.
PS
I also 'pip' installed pythonwin for the oldschool programming experience (with code folding) and Jupyter (QT console) as other IDE's. Search this site for those that use others like pycharm etc
I respectfully disagree with you Dan: definitely not drivel!
No surprise the toolbox script didn't work straight away. ESRI has had to make some fundamental changes to arcpy for Pro. This means you need to either update the arcpy code to work in Pro only, or write code to deal with the differences so as to make the scripts compatible with both Pro and ArcMap.
The latter is definitely doable. I have converted a complex toolbox with some 50 tools originally developed in ArcMap, to be fully compatible with both Pro and ArcMap. It does mean your code will contain a lot of if..elif statements to deal with the differences, but ultimately, that is not a real big issue, and the number of places you need to insert it in single script is usually limited, as still a lot of the arcpy stuff is compatible between Pro and ArcMap. Usually, only small parts of the script code need to be inside an if..elif or if..else to deal with Pro/ArcMap compatibility, the rest of the code remains unchanged.
Do note that it will certainly take time to familiarize yourself with the differences and how to deal with them. As said, it is doable, but you may run into issues initially trying to understand how to convert code. Nonetheless, ESRI has resources for this, the main stop being this Help page with useful links:
Migrating from arcpy.mapping to ArcGIS Pro—ArcPy | ArcGIS Desktop
As a starter, the following code example shows some minimum stuff all of your scripts will need if you strive for ArcMap/Pro dual compatibility (for some reason, the "Source Code" option of GeoNet does not seem to work? so I insert it directly in the text):
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import
import arcpy
# GetInstallInfo
installInfoDict = arcpy.GetInstallInfo()
productName = installInfoDict["ProductName"]
if productName in ["Desktop","Server","Engine"]:
# Your ArcMap code
elif productName in ["ArcGISPro"]:
# Your Pro code
See this blog post for some images etc of Spyder ... particularly in the Comments section
Interesting stuff guys, thank you for the great information and links!