Skip to content

Instantly share code, notes, and snippets.

@gavinr
Last active March 19, 2019 19:17
Show Gist options
  • Save gavinr/209880e1e23eb33b033b6d1d84fb5fcd to your computer and use it in GitHub Desktop.
Save gavinr/209880e1e23eb33b033b6d1d84fb5fcd to your computer and use it in GitHub Desktop.

Create a new ArcGIS Python API Environment

First Time

  1. Install conda with Anaconda for Python Distribution. Conda is a python package manager that will install python 3.x and other packages listed in the environment.yml file.
    • Choose the 3.x version
    • Note: Make sure to check "Add to PATH environment variable"
  2. Restart your computer. Because you added conda to the PATH variable, you should be able to use the conda command in any terminal (Windows command prompt, Powershell, etc). Open a terminal and type conda to make sure the conda command is recognized.
  3. In the terminal, navigate to the location of your code repository.
  4. Create a new environment with Conda (more info)

    conda env create --name projectname

  5. Activate the environment:

    conda activate projectname

  6. Install the ArcGIS API for Python into the new environment: (more info)

    conda install -c esri arcgis -n projectname

  7. Export the YML file and save it to your SCM:

    conda env export > environment.yml --name projectname

    • Note, every time you install another package into the environment, you should re-export this environment.yml file and save to SCM.

Secondary Computers

Once you've done the above and saved the environment.yml file to your SCM, to get the same environment going on a new computer:

  1. Run steps 1-3 from above.
  2. Create a new environment with Conda, and install all the packages listed in environment.yml:

    conda env create --name projectname --file environment.yml

  3. Activate the environment:

    conda activate projectname

VS Code

  1. Make sure you select your new environment by opening the Command Palette (CTRL + P), choosing "Python: Select Interpreter" and choose your envioroment. Note that sometimes I have to close/open VS Code to get it to appear here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment