Skip To Content

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.

ArcGIS Pro has a default conda environment, arcgispro-py3, that 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 on the experience of Python in the ArcGIS Pro app, see Python Package Manager.

Questions and answers

Note:

All answers in this section assume ArcGIS Pro is installed under c:\Program Files\ArcGIS. For a per-user install or an install to a custom location, simply 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.6\python.exe my_script.py

Now, you can run the same script using the following updated path:

"c:\Program Files\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:\Program Files\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 could 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:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe (the default conda environment for ArcGIS Pro), you would not necessarily have the same set of packages as you are using inside the ArcGIS Pro application. This is why you would want to 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?

  • 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. 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 admin privileges required to install conda packages?

No, as of ArcGIS Pro 2.2, the default arcgispro-py3 environment is read-only and cannot be modified even when running ArcGIS Pro with admin privileges. To install conda packages, a user can create a new environment through the ArcGIS Pro Package Manager, or conda command line utilities.

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

This is a warning telling you that you cannot use conda commands to modify conda environments or packages. However, this does not impact using Python (including proenv.bat and propy.bat). See the previous question regarding administrative privileges.

Related topics


In this topic
  1. Questions and answers