-
Notifications
You must be signed in to change notification settings - Fork 1
Setting Up In ArcGIS Pro
This method is an option to use instead of the previous method - if you have already followed the steps in the prior sections, you do not need to continue on in this document
This project requires us to create a new Conda environment, a structure that helps isolate this code and its dependencies from other code running on ArcGIS Pro. Full instructions on creating a new Conda environment can be found here, but are summarized below for this project.
- Ensure ArcGIS Pro 1.3 or above is installed on your machine.
- In Windows, navigate to
C:\Program Files\ArcGIS\Pro\bin\Python\envs
- Copy the folder
arcgispro-py3
and paste it into the same folder - Rename the copied folder to
arcproject-wq
, leaving the main folder namedarcgispro-py3
intact.
You've now created a new environment, but ArcGIS Pro can't use it until we activate it.
- Open a command prompt as an administrator (in the start menu, type "CMD", and while holding shift, right click on the Command Prompt result and select "Run As Administrator")
- Type
cd "C:\Program Files\ArcGIS\Pro\bin\Python\Scripts"
and hit Enter to execute the command - Type
proswap arcproject-wq
and hit Enter to execute it
The proswap
command tells ArcGIS which Conda environment to use - since we put arcproject-wq
afterward, it looks for an environment with that name in the envs
folder and makes it the default Python environment when working inside of ArcGIS Pro, and makes it available for use when executing code outside of ArcGIS Pro.
Since ArcGIS Pro comes preinstalled with many of the necessary dependencies, this process is much easier.
- Open a command prompt with administrator access (you may reuse the existing prompt if you'd like).
- Navigate to the folder that has the arcproject distribution (a Python "wheel" file - extension ending in ".whl")
- Run
"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcproject-wq\pip" install -r requirements.txt
- Python will then look at all of the items specified in the file requirements.txt in the arcproject directory and install any missing items from the Internet.
You should now have everything you need installed. In order to run code, you can do either of the following.
Please Note: ArcGIS Pro software updates can break Conda environments and may require you to recreate it using the procedure above.
All you need to do in order to run the code in ArcGIS Pro is make sure that the Conda Environment stays activated and then add the toolbox in ArcGIS Pro. If you open a project in ArcGIS Pro and go to the Insert
tab, you can select the Toolbox
dropdown and choose Add Toolbox
. From there, navigate to the folder that has the arcproject code in it and choose wq-processing-toolbox.pyt
(single click), then click Open
. Afterward, the tools will be available from the Geoprocessing
pane if you go to the Toolboxes
view.
On the command line, you'll need to invoke the conda environment's interpreter to get access to the appropriate code. I recommend creating a batch file named python.bat
in the main arcproject directory that has the full path to the appropriate copy of Python ("C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcproject-wq\python"
) as the only line inside of it. Then, from the directory in a command prompt, you can type "python" and have it give you the correct interpreter.