Run stand-alone scripts

ArcGIS Pro includes a default, read-only conda-based Python. This Python is used in ArcGIS Pro, and it is also the Python you use to run stand-alone scripts.

This default conda environment, arcgispro-py3, includes all Python libraries used by ArcGIS Pro as well as several others such as scipy and pandas. There are several shortcuts for accessing this environment, including the Python Command Prompt shortcut, which opens a command prompt initialized with the arcgispro-py3 environment.

For more information about Python in the ArcGIS Pro app, see Python Package Manager.

Questions and answers

Remarque :

All answers in this section assume ArcGIS Pro is installed under c:\Program Files\ArcGIS. For a per-user installation or an installation to a custom location, update the path.

How do I run a stand-alone script?

In other ArcGIS products, a Python script is run from a command prompt as follows:

c:\python27\ArcGIS10.7\python.exe my_script.py

In ArcGIS Pro, you can run the same script using the following updated path:

c:\Progra~1\ArcGIS\Pro\bin\Python\scripts\propy.bat my_script.py

Here, propy.bat acts as a replacement for calling python.exe.

Do I need to activate the conda environment to run a stand-alone script?

No. You can use python.exe under c:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3 to run your scripts. You can also call c:\Progra~1\ArcGIS\Pro\bin\Python\scripts\propy.bat as mentioned previously.

Why would I want to use propy.bat?

While working in an ArcGIS Pro project, you can create and use the new conda environment with specific sets and versions of Python packages. For example, when running stand-alone scripts, if you run c:\Progra~1\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe (the default conda environment for ArcGIS Pro), you will not necessarily have the same set of packages you are using in the ArcGIS Pro application. This is why you use propy.bat: it determines the application’s active conda environment and activates it in your stand-alone script.

What is the difference between propy.bat and proenv.bat?

The differences are as follows:

  • propy.bat—A replacement for python.exe. It activates the ArcGIS Pro conda environment arcgispro-py3 and launches Python. You can call propy.bat with or without a Python file as an argument.
    • With a script as argument, propy.bat does the following:
      1. Activates the ArcGIS Pro conda environment
      2. Starts Python
      3. Runs the specified script
      4. Exits Python and the environment
    • If you can call propy.bat without argument, the conda environment is activated, and Python is launched in interactive window mode (REPL).
  • proenv.bat—Activates the ArcGIS Pro environment and opens the Windows Command Prompt window. From there, you can call arcgispro-py3\python.exe by typing Python to start an interactive terminal session, or type python followed by the name of the script you want to run.

Are administrative privileges required to install conda packages?

No. As of ArcGIS Pro 2.2, the default arcgispro-py3 environment cannot be modified using the ArcGIS Pro Package Manager, even when running ArcGIS Pro with administrative privileges. To install conda packages, you can create an environment through the ArcGIS Pro Package Manager or conda command line utilities.

Remarque :

The default arcgispro-py3 environment can be modified using conda command line utilities; however, this is not generally recommended. Modifying the arcgispro-py3 environment on a per-machine ArcGIS Pro installation requires administrative privileges.

When I launch the Python Command Prompt window, why do I get an access is denied error?

You cannot use conda commands to modify conda environments or packages. However, this does not impact your use of Python (including proenv.bat and propy.bat). See the previous question regarding administrative privileges.

Rubriques connexes


Dans cette rubrique
  1. Questions and answers