1. Understand
Because Python is a free cross-platform open source programming language, it is easy to operate and has strong scalability (rich library types). ArcGIS introduced it in ArcGIS 9.0.
Conda is a commonly used and widely used Python package management program. So Conda is integrated in ArcGIS Pro.
Run Python interactively in ArcGIS Pro using the Python window or ArcGIS Notebooks.
2. Operation mode
2.1Python window
The Python window provides a prompt where you can run a short snippet of Python code.
2.2ArcGIS Notebooks
ArcGIS Notebooks are based on the Jupyter Notebook architecture and provide a rich experience in which code, visualizations, and initiative text can be run and stored together in the same document.
Prompt message settings
After entering the main module, enter "." and then hold down the Tab key to display the functions under this module.
2.3 Program external operation
Use the ArcGIS Pro Python 3 conda environment to run Python scripts externally to ArcGIS Pro applications.
propy.bat can determine an application's active conda environment and activate it in a stand-alone script. propy.bat is located in the installation environment
"%PROGRAMFILES%\ArcGIS\Pro\bin\Python\Scripts\propy"。
If propy.bat is called without arguments, the conda environment will be activated.
Test file content
import arcpy
arcpy.AddMessage("----利用ArcGIS Pro环境在应用程序外部运行py----")
cmd command
"D:\Program Files\ArcGIS\Pro\bin\Python\Scripts\propy" externalPyTest.py
operation result
2.4Python interactive terminal
This method uses the conda environment synchronized with ArcGIS Pro
2.5IPython
ipython
It is an python
interactive tool shell
that is much easier to use than the default one python shell
. It supports automatic completion of variables, automatic indentation, supports bash shell
commands, and has many useful features and functions built-in.
2.6python.exe
Directly find the python environment we need to operate
CodeprintTest.py
print("Z_W_H_")
operation result
Relevant content will also be synchronized to the WeChat official account. Please pay attention to it. If you have relevant groups, you can also join the group to communicate.