Q: Is there an Object Model Diagram or Cheatsheet for ArcPy?
A: While we have decided against producing an Object Model Diagram for reasons outlined here, we do offer an ArcPy Cheatsheet.
Q: What version of Python and/or <insert package name> are currently installed with the default Python environment in ArcGIS Pro (arcgispro-py3)?
See Available Python libraries—ArcGIS Pro | Documentation
Q: My custom ATBX script tool that uses dunder file (__file__) no longer works after I upgraded from an earlier version ArcGIS Pro to 3.2 or greater, why?
At Pro 3.2, the value in the __file__ variable was changed for embedded scripts (for both validate and execute) inside .atbx files.
Normally this __file__ variable is used to reference external resources that are deployed in a folder relative to the .atbx.
At 3.1 the value in __file__ was:
At 3.2 the value in __file__ is:
Note: this only affects validate and execute scripts inside a .atbx file. Validate and execute scripts stored outside the .atbx (as a .py file on disk) are unaffected. Additionally, embedded scripts in a .tbx file are unaffected.
Updating the affected code:
The affected code we typically see is os.path.dirname(__file__).
The proposed replacement code is os.path.dirname(__file__.split(".atbx")[0]).
This proposed replacement code will work in embedded validate as well as embedded execute scripts. This code will produce desired and consistent result with the __file__ in Pro 3.2 as well as earlier releases.
import os # Show how various mock __file__ values from 3.1 & 3.2 are processed
# using the proposed method: for __file__ in [
r"C:\Path\MyToolbox.atbx#MyTool_MyToolbox.py", # execute Pro 3.1
r"C:\Path\MyToolbox.atbx#MyTool_MyToolbox.UpdateParameters.py", # validate Pro 3.1
r"C:\Path\MyToolbox.atbx\MyTool.tool\tool.script.execute.py", # execute Pro 3.2
r"C:\Path\MyToolbox.atbx\MyTool.tool\tool.script.validate.py", # validate Pro 3.2
]:
print(os.path.dirname(__file__.split(".atbx")[0]))
Since their integration into ArcGIS Pro 2.5, Notebooks in ArcGIS Pro have been based on the open-source IPython Jupyter Notebook. Meanwhile, the community of Jupyter developers have been heavily investing in a major redesign known as JupyterLab. This major redesign breaks backwards compatibility with extensions and many classic notebook features and customizations. At this time, the classic notebooks (up to version 6) have been deprecated and are superseded by JupyterLab based notebook 7 and up. This means that in order to continue to benefit from the latest features, maintenance, and security patches, ArcGIS Pro is moving to notebooks based on the JupyterLab framework.
At the ArcGIS Pro 3.4 release, notebooks have been upgraded and are now backed by JupyterLab 4.2.4 and Notebooks 7.2.1. With this upgrade there are some notable changes, such as a cleaner interface, a more modern look, and new features:
Additionally, users of Notebooks in ArcGIS Pro are now able to run ipywidget interactive widgets, PIL.Image, and a wider set of magic commands.
Q: How does the experience of running an ArcGIS Notebook in ArcGIS Pro compare with running a Jupyter Notebook outside of Pro?
A: With notebooks in ArcGIS Pro, you can open a map view and a notebook view side-by-side, allowing you to visualize and directly interact with the data.
Q: Can I use the standard Jupyter Notebook keyboard shortcuts?
A: Keyboard shortcuts work just like they do in Jupyter Notebook.
Starting at 3.0 we intentionally disabled the print, browse forward, and browse backward shortcuts, and enabled the zoom and find shortcuts. At 3.4 we have also disabled the Command Palette shortcut CTRL+SHIFT+C, but will assess bringing it back in a later release.
Q: Why are figures from matplotlib not showing up in the cell output of my notebook?
A: Inline visualizations from matplotlib are supported since ArcGIS Pro 2.6. Starting at ArcGIS Pro 3.1, you no longer need to call matplotlib.pyplot.show to display the plot inline. However, it is still recommended that you use the show method to avoid displaying the object representation string of your plot, which may be unnecessary or distracting. For example:
%matplotlib inline # Imports import matplotlib.pyplot as plt import pandas as pd import arcgis # Create spatially enabled data frame (SEDF) sedf = pd.DataFrame.spatial.from_featureclass("USA_States_Generalized") # Create plot plt.bar(sedf.STATE_NAME, sedf.POP2010) # Update plot elements plt.suptitle("Population of New England States", fontsize=16) plt.ylabel("Population (in millions)") plt.xticks(rotation=45) # Draw the plot plt.show()
Q: Why does a new instance of ArcGIS Pro launch when I run %pip from a notebook cell?
A: This is a known issue with embedded Python interpreters (such as what is running in ArcGIS Pro). Magic commands use the output of sys.executable to determine the host process, which in this case launches ArcGISPro.exe and not pythone.exe. You can avoid this by prefixing the pip command with ! instead of %. Note that we recommend using conda over pip.
Q: Where can I find the option for restarting the kernel?
A: You currently cannot restart the kernel unless you close and reopen ArcGIS Pro. You can, however, interrupt the kernel using the Interrupt Kernel button on the Notebook ribbon. While not a complete workaround, you can also use the %reset -f magic command to clear all variables in the namespace.
Q: Can I use R or C# in my notebook instead of Python?
A: You can only open a Python kernel in notebooks running in ArcGIS Pro, other languages are not supported.
Q: I'd like to export my notebook (.ipynb) to a Python script (.py), is that possible?
A: Yes, you can export a notebook to a Python (.py) or HTML (.html) file from the Notebook ribbon’s Export button.
You can also use the Jupyter command nbconvert from the command prompt, or you can run the command directly from your notebook by preceding the command with an exclamation mark (!).
!jupyter nbconvert --to script "Path\To\Your_Notebook.ipynb"
The resulting Your_Notebook.py file will be in the same directory as your notebook, Your_Notebook.ipynb.
Q: Can I open a Jupyter notebook in ArcGIS Pro that I have previously created outside of Pro?
A: Yes, ArcGIS Notebooks are simply Jupyter Notebooks and any notebook can be run in ArcGIS Pro. However, it is your responsibility to ensure any libraries used in these other environments are available in the active environment of ArcGIS Pro.
Q: Can I use my ArcGIS Notebook created in Pro across other platforms?
A: ArcGIS Notebooks are simply Jupyter Notebooks (.ipynb) and can be run in any Jupyter environment or as hosted ArcGIS Notebooks in ArcGIS Enterprise or ArcGIS Online. However, it is your responsibility to make sure that any libraries used in the notebook are available in these other environments.
Q: When opening a notebook in ArcGIS Pro, why did I receive a "Failed to load notebook" error?
A: Notebooks in Pro leverage a webserver run as localhost on port 8778. If it cannot be reached or is otherwise interfered with, notebooks will fail to load. Known causes and solutions:
Q: Can I open a notebook in Pro from a UNC path?
A: UNC paths are supported as of ArcGIS Pro 3.0 - just be careful about collisions as this opens up the possibility of multiple users editing the same file. If you are still on an earlier version of ArcGIS Pro and unable to upgrade, the best workaround is mapping the UNC path to a drive or alternatively creating a symbolic link.
Q: I keep clobbering variables when I have multiple notebooks open in Pro. Why are variable names being shared across multiple notebooks?
A: ArcGIS Pro runs a single Python instance. This execution context is shared by each notebook opened in a single instance of ArcGIS Pro. Depending on the contents of concurrently open notebooks, this could potentially result in variable name collisions. To avoid potential issues you may consider:
Q: Why are the environment variables I set in Notebooks (or Python Window) not being honored by Geoprocessing tools I run from the Geoprocessing pane?
A: This behavior is due to the environment levels hierarchy.
When setting an environment variable using arcpy.env, you are setting it at the Script level. Since this is the lowest level in the hierarchy, the setting will not be honored at any of the above levels. In order for your environment variables to be honored by both Script and Geoprocessing tools, you must set the environment variables using the Application settings from your project.