With ArcGIS Pro 1.3, there are some significant changes to Python. These changes primarily affect how you run standalone scripts with Python. The experience of Python within the ArcGIS Pro app is unchanged.
Documentation can be found here http://pro.arcgis.com/en/pro-app/arcpy/get-started/installing-python-for-arcgis-pro.htm, but additional information is included below.
Just one install of Python
There is no longer a secondary install of Python needed to run standalone scripts with Pro. In ArcGIS Pro 1.0, 1.1 and 1.2 a lightweight version of Python was used within the application, but to run standalone Python scripts you had to install a secondary “Python for ArcGIS Pro”.
At 1.3, ArcGIS Pro will install Python into the ArcGIS\Pro\bin\Python\envs\arcgispro-py3. This Python is used within the ArcGIS Pro application and it is also the Python you use to run standalone scripts.
ArcGIS Pro 1.3 uses conda
Over the last few years, conda from Continuum analytics has gained significant traction in the Python community as a package and environment manager.
At 1.3, ArcGIS Pro includes conda, and the Python that you use with arcpy and ArcGIS Pro is in a conda environment named “arcgispro-py3”. With an install of ArcGIS Pro for “all users”, arcgispro-py3 will be found at C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3 . With an “only for me” install of ArcGIS Pro, arcgispro-py3 will be found at C:\Users\<user name>\appdata\local\Programs\ArcGis\Pro\bin\Python\envs\arcgispro-py3
Note: Conda is written and implemented with Python. So if you browse into ArcGIS\Pro\bin\Python\, you’ll see an install of Python. This is not the Python you’re looking for. You will not be able to use the arcpy module when running with this interpreter.
Questions & Answers
Note: All answers assume an install for “all users” (e.g., c:\Program Files\ArcGIS…), for user install, or install to custom location, simply update the path.
Q: How do I run a standalone script?
A: In previous releases of ArcGIS, a Python script was run from a command prompt like below:
c:\data> c:\python34\python.exe my_script.py
Now, you’ll run you the same script like below:
c:\data> "c:\Program Files\ArcGIS\Pro\bin\Python\scripts\propy.bat" my_script.py
Here propy.bat acts as a replacement for calling python.exe.
Q: Do you have to activate the conda environment to run a standalone script?
A: No, you can simply replace calls to
with calls to
Or, you can also call ArcGIS\Pro\bin\python\scripts\propy.bat as mentioned above
Q: If I can run envs\arcgispro-py3\python.exe, why would I want to use propy.bat?
A: In future releases, you’ll be able to create, and change conda environments within ArcGIS Pro. So, while working on a given Pro project you could create and use a new conda environment with specific sets and versions of Python packages. When running standalone scripts, if you run envs\arcgispro-py3\python.exe (ArcGIS Pro's default conda environment) it would NOT necessarily have the same set of packages as you are using inside the ArcGIS Pro application. This is where propy.bat comes in, it determines the application’s active conda environment and activates it in your standalone script.
Q: There is also proenv. What is the difference between propy & proenv?
A: As follows
- propy.bat : is a replacement for python.exe, it activates the ArcGIS Pro conda environment (arcgispro-py3) and then launches python, you can call propy.bat it with or without a py script as an argument.
- With a script as argument which will:
- Activate the ArcGIS Pro conda environment
- Start Python
- Run the script specified
- Exit Python and the environment
- If you can call propy.bat without argument, the conda environment will be activated, and python will be launched in interactive window mode (REPL).
- With a script as argument which will:
- proenv.bat : activates the ArcGIS Pro environment, and leaves the user in at the windows command prompt. From there you can easily call arcgispro-py3\python.exe by typing Python to start an interactive terminal session (REPL session), or type ‘python’ followed by the name of the script you wish to run.
Activating environment "c:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py
[arcgispro-py3] c:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3>cd c:\my_proj
Python 3.4.4 |Continuum Analytics, Inc.| (default, Feb 16 2016, 09:54:04) [MSC v
.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import arcpy
Q: When in the command prompt, why does proenv.bat change my current working directory?
A: This behavior will be reviewed in the next release. To avoid this behavior you can launch Python Command Prompt (which calls proenv.bat) from the start menu instead of calling it from the Windows Command Prompt.
Q: Are admin permissions required to install conda packages?
A: If you have an "all users" install of ArcGIS Pro, the default install location is within the Program Files folder. To make changes to this folder location will require the applications to have elevated (admin) credentials. And since the Python environments is stored within the ArcGIS Pro application, then yes installing/removing/updating packages as well as creating and deleting environments will require elevated credentials. To get elevated credentials (admin privileges) from the Windows Application launcher you can right click on Command Prompt, or Python Command Prompt and choose Run as Administrator.
Q: When I launch the Python Command Prompt I get an error “Access is denied. Could Not Find proenv.txt. Insufficient privileges.
A: 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 itself (including proenv & propy.bat). See previous question regarding administrative permissions.
Something else you’d like to ask? Something missing from this Q & A? Please go to https://geonet.esri.com/community/developers/gis-developers/python and post there.
Integrate Development Environments (IDEs)
As mentioned above, environments are a ‘best practice’ with the Python community. However you have to tell the IDE which environment it needs to use.
For information on using most of the popular IDEs with a conda environment see https://docs.continuum.io/anaconda/ide_integration
Do note that PyScripter does not work well with virtual environments, therefore cannot be used with Python included in ArcGIS Pro 1.3. Some good alternatives for PyScripter are
- PyCharm : a newer and extremely popular IDE with lots of bells and whistles.
- Python Tools for Visual Studio : a plugin for Microsoft’s very powerful IDE, requires MS Visual Studio (there is a free community edition).
- WingIDE : another very popular full fledged IDE, there is a free community edition and a more full featured “pay” edition.
- Spyder : an IDE with a focus on Scientific Python. Very easy to install with conda, simply
C:\data> "c:\Program Files\ArcGIS\Pro\bin\Python\Scripts\proenv.bat"
C:\data> conda install spyder
Then you can launch spyder from the Windows start menu.
Below are examples showing how to update IDE settings for Python Tools for Visual Studio and PyCharm to use arcgispro-py3.
The examples use path to environment at C:\Program Files\ArcGIS\Pro\bin\python\envs\arcgispro-py3 which is where you’ll find it if you installed ArcGIS pro for “all users”. If you installed “Only for me” the default path is here C:\Users\ghis3080\AppData\Local\Programs\ArcGIS\Pro\bin\python\envs\arcgispro-py3
Python Tools for Visual Studio
Relevant document from Microsoft is here: https://github.com/Microsoft/PTVS/wiki/Python-Environments
Select Tools\Options then in the options go to the Python Tools\Environment Options in the tree view, click the Add Environment setting, for a name you can use “arcgispro-py3” (or a name of your choice).
Then add the following settings
- Path : C:\Program Files\ArcGIS\Pro\bin\python\envs\arcgispro-py3\python.exe
- Windows Path : C:\Program Files\ArcGIS\Pro\bin\python\envs\arcgispro-py3\pythonw.exe
All subsequent settings are optional.
PyCharm Community edition
In File\Settings…, choose Project then Project Interpreter
Ignore the drop down list for Project Interpreter, and click the cog button to Add Local, and in the file browser pick C:\Program Files\ArcGIS\Pro\bin\python\envs\arcgispro-py3\python.exe
Note that the default for “me only” install is in C:\Users\<user_name>\AppData\Local\Programs\ArcGIS\Pro\bin\Python\envs\arcgispro-py3 . This path may not be visible from the file browser. This shortcut can be copy/pasted %LOCALAPPDATA%\Programs\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe
No other change should be required.
To run your script, right click it in the Project window, and choose either Run or Debug
Restart PyCharm for the Python Console to use the arcgispro-py3 environment.
For more information on conda in ArcGIS Pro, see: