I see a lot of Q&As asking how you can create a separate Python installation (e.g. the Anaconda or Python XY distribution) that can use arcpy, while not 'breaking' the original ArcGIS python installation.

I had this same problem, and I think I have found a 'universal' solution. So far we have done this on about 8 computers at work and it all works fine.

How to install a separate Python distribution that can use ArcGIS?

4 Answers 4


I created a small (and relatively popular) module which goes off and hunts for ArcGIS on your PC. Once find it adds the correct paths to the environment so that you can import arcpy. The usage goes like this:

    import archook #The module which locates arcgis
    import arcpy
except ImportError:
    # do whatever you do if arcpy isnt there.

The module is hosted on github here: https://github.com/JamesRamm/archook

It is very simple and I'm sure can be made more robust, but it does the job. It is available on pypi: pip install archook

It has a few advantages over the more 'manual' original method (detailed below):

  1. You dont need to configure each python environment separately...just import the module and off you go
  2. It does not edit/create any registry keys or permanent environment variables, so there is no chance of messing up any existing python/arcgis configuration.
  3. You dont need to know anything about paths to various folders/files, or even what version of arcgis you have installed. The module will find it all for you.
  4. No admin authentication needed
  5. It is not specific with anaconda - it will work with any python installation

I have left the original answer below, but this solution is (IMO) 100% better.

2014 answer

Ok, so this answer works for the Anaconda 64bit Python distribution with ArcGIS 10.1 64bit on Windows 7/Windows Server. Some of (or all) of the tips given below may apply to any other windows distribution of python. First, install anaconda, it should go to the directory C:\Anaconda. Check the box 'make system default python'. It may give a warning that there is another python installed, but continue. Then:

Setup Paths and Environment Variables

First thing to do is to copy over the DTBGGP64.pth file to the new distribution directory (C:\Anaconda) from C:\Python27\ArcGISx6410.1\Lib\site-packages. The naming is arbritrary, but must have the .pth extension This will allow you to import ArcPy when using the new distribution. Note: The correct location of the DTBGGP64.pth file should be in the site-packages directory (e.g. C:\Anaconda\Libs\site-packages). I have found that with some older versions of Anaconda, it works if sat in the top level directory Next, the environment variables must be checked: In the system variable Path, the existing path to the python directory should be replaced with the new path. (e.g. C:\Anaconda;C:\Anaconda\Scripts;) This will tell windows where the default python directory is. Make sure the user variable PYTHONPATH is also correct. This should point to any libraries you wish to use which are not described by .pth files or are installed in site-packages. I.E this might be your own development packages, or packages such as mapnik which have a different installation location.

Check Registry Settings

On some machines, the above may be enough to ensure that you can use arcpy from the new python and that python can be used within ArcGIS. On other machines, you may need to check registry keys. The following registry keys have python settings:

There should be one key and its’ value should be C:\Anaconda\Lib;C:\Anaconda\DLLs (Or the corresponding folders for your python installation)

The key should be C:\Anaconda

You may have other python versions installed...in which case change the version number in the above paths

HKEY_CLASSES_ROOT\Python.CompiledFile\DefaultIcon This is the location of the .ico file to use for .pyc files

HKEY_CLASSES_ROOT\Python.CompiledFile\shell\open\command This is the command to issue when opening a .pyc file from the shell. You should change the python.exe path to the location of your desired python version

HKEY_CLASSES_ROOT\Python.File The keys here are the same as those for Python.CompiledFile except that they apply to a .py file. Again, make the relevant changes. It may have an extra key for 'Edit with IDLE' or 'Edit with Pythonwin'. Again, make the relevant changes so that the paths in these keys point to your desired python version.

HKEY_CLASSES_ROOT\Python.NoConFile These are the same as for Python.File, but should point to the pythonw.exe program where appropriate.

The PythonDir key points to the python installation to use within ArcMap etc.. You may wish for this to remain as the python installation as installed by ESRI, or point it to your new installation. It may require other changes if you point ArcMap to the new python installation. There may be issues with the versions of packages (e.g. numpy) installed by the new distribution. I have not encountered any.

For the majority of my work, this is irrelevant as I typically want to use python on it's own and occasionally have access to arcpy. I rarely wish to use python from within arcmap..Therefore I have done little testing of this final step, but it seems to work for everything I have tried so far.

I imagine that the process would be similar for installing Python(x,y) etc.

Other notes

The contents of the .pth file is a list of paths pointing to the following folders in your ArcGIS installation: bin64, arcpy, ArcToolbox\Scripts For example, my .pth file contains the following:

C:\Program Files (x86)\ArcGIS\Desktop10.2\bin64
C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy
C:\Program Files (x86)\ArcGIS\Desktop10.2\ArcToolbox\Scripts

  • Does this install all the Python dependencies ArcGIS has? matplotlib, numpy, xlrd, xlwt and dateutil?
    – KHibma
    Commented Feb 18, 2014 at 14:41
  • Yes. For the anaconda distribution, a full list of of packages can be found here: docs.continuum.io/anaconda/pkgs.html I am not as familiar with Python(x,y) or other distributions
    – James
    Commented Feb 18, 2014 at 14:43
  • 2
    Don't forget that ArcGIS (10.2 and 10.1) has very specific version requirements for numpy - must be 1.6.1 or you can break arcpy.
    – user2856
    Commented Feb 18, 2014 at 23:22
  • 1
    Please add the contents of the DTBGGP64.pth file! Many users don't seem to have this. :)
    – mmann1123
    Commented Oct 28, 2014 at 21:29
  • 1
    A really nice feature of anaconda is you can set it up with virtual environments with the versions you need for ArcGIS or any other package. For example, you could have a virtual environment set up to work with ArcGIS that has the versions that Esri tools are expecting, and another one that doesn't include arcpy when working totally outside of arcgis. Commented Feb 13, 2015 at 18:31

My solution is to set up a startup script that sets of the path based on the python environment you are using. This method has the (huge) advantage that you don't need admin access to write .pth files in python installations. This script is setup to use both 32 bit and 64 bit Anaconda and ArcGIS/arcpy.

    # Startup script to link Anaconda python environment with ArcGIS
    # 1. Install Anaconda, setup environment to match your ArcGIS version
    # 2. Edit the paths below
    # 3. Put this startup script in the startup folder as "usercustomize.py"
    #    Startup folder can be found with: "C:\Python27\ArcGIS10.2\python -m site --user-site"
    #    Usually will be:
    # C:\Users\%USERNAME%\AppData\Roaming\Python\Python27\site-packages

    import sys
    import os

    # edit these paths to match your setup
    arcver = "10.2"
    # Anaconda home folders
    conda32 = r"D:\Users\cprice\Anaconda"
    conda64 = r"D:\Users\cprice\Anaconda64"
    # here are the conda environments you've set up use with ArcGIS
    # arc1022 is the environment setup for ArcGIS
    conda_env32 = "{}/envs/{}".format(conda32, "arc1022")
    conda_env64 = "{}/envs/{}".format(conda64, "arc1022")

    # do not edit below this line

    # ArcGIS Python home folders
    # i.e. C:\Python27\ArcGIS10.2
    arcver = arcver[:4]
    arcpy32 = r"C:\Python27\ArcGIS{}".format(arcver)
    arcpy64 = r"C:\Python27\ArcGISx64{}".format(arcver)

        if sys.version.find("64 bit") < 0:
            conda_path = os.path.normpath(conda_env32)
            arcpy_path = os.path.normpath(arcpy32)
            arcpy_pthfile = os.path.normpath(
                arcpy_path + "/lib/site-packages/desktop{}.pth".format(arcver))
            conda_path = os.path.normpath(conda_env64)
            arcpy_path = os.path.normpath(arcpy64)
            arcpy_pthfile = os.path.normpath(
                arcpy_path + "/lib/site-packages/DTBGGP64.pth")

        for p in [conda_path, arcpy_path, arcpy_pthfile]:
            if not os.path.exists(p):
                raise Exception("{} not found".format(p))

        ## print(sys.prefix)
        ## print(conda_path)

        # If running ArcGIS's Python, add conda modules to path
        if (sys.executable.lower().find("desktop" + arcver) != -1
            or sys.prefix.lower().find("arcgis10") != -1):
            conda_site = os.path.join(conda_path, "lib", "site-packages")
            if not os.path.isdir(conda_site):
                raise Exception()
            print("usercustomize.py: added conda paths to arc")

        # if running Anaconda add arcpy to path
        elif sys.prefix.lower() == conda_path.lower():
            with open(arcpy_pthfile, "r") as f:
                sys.path +=  [p.strip() for p in f.readlines()]
            print("usercustomize.py: added arcpy paths to conda")

    except Exception as msg:
  • How are you setting/calling this strartup script for virtualenv in other .py scripts? for example, if you just have a .py script that is "arcpy.CopyFeatures_management('myinput.shp', 'myoutput.shp')" ? Simplified example of course. Thx for any advice
    – a11
    Commented Jul 17, 2019 at 15:14

In case anyone is trying to do this using ArcGIS Pro (i.e. with python 3 instead of python 2):

I use spyder within the anaconda package. The way I got this to work was by going to Tools > Python Interpreter in Spyder, then pointing Spyder to the propy.bat file currently located at C:\Program Files\ArcGIS\Pro\bin\Python\Scripts\propy.bat.

This activates the correct python version in Spyder and allows you to import arcpy.


I use the following code to setup a separate Virtual Environment, containing arcpy and it dependencies:

set "VENV_PATH=C:\VirtualEnvs\MyArcPyEnv"
set "PYTHON=C:\Python27\ArcGIS10.3"

mklink /J %VENV_PATH%\Lib\site-packages\arcpy "C:\Program Files (x86)\ArcGIS\Desktop10.3\arcpy\arcpy"
mklink /J %VENV_PATH%\Lib\site-packages\numpy %PYTHON%\Lib\site-packages\numpy

mklink /J %VENV_PATH%\Lib\site-packages\matplotlib C:\Python27\ArcGIS10.3\Lib\site-packages\matplotlib
mklink /J %VENV_PATH%\Lib\site-packages\dateutil %PYTHON%\Lib\site-packages\dateutil
mklink /J %VENV_PATH%\Lib\site-packages\mpl_toolkits %PYTHON%\Lib\site-packages\mpl_toolkits

copy %PYTHON%\Lib\site-packages\pyparsing.py  %VENV_PATH%\Lib\site-packages
copy %PYTHON%\Lib\site-packages\pylab.py %VENV_PATH%\site-packages
copy %PYTHON%\Lib\site-packages\netcdftime.py %VENV_PATH%\Lib\site-packages
copy %PYTHON%\Lib\site-packages\netCDF4_utils.py %VENV_PATH%\Lib\site-packages

REM Only one of the following .pth files will exist (dependent on x64 or x32)

copy %PYTHON%\Lib\site-packages\Desktop10.3.pth %VENV_PATH%\Lib\site-packages
copy %PYTHON%\Lib\site-packages\DTBGGP64.pth %VENV_PATH%\Lib\site-packages

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.