I'm getting a new computer and am trying to set up my virtual environments the right way. In the past, I've just been using PyCharm and running everything through "C:\Python27\ArcGIS10.6" so it's a miracle I haven't broken ArcPy yet on my old computer.

I'm setting up virtual environments for:

  1. just ArcPy with ArcMap (so, Python 2.7); and
  2. Python 3.x for GDAL and other things

I'm following @CurtisPrice’s answer to Making separate Python installation that can call ArcPy? to set up virtual environments.

There is a simple example below, where I am writing and running a .py script in PyCharm.

Do I now just call @CurtisPrice's *.py file to set the virtual environment?

usercustomize.py   ## is this how I set the virtual environment???
import arcpy

myshp = r'C:\Users\name\path\myfile.shp'
arcpy.AddField_management(myshp, "new_field", "SHORT")

1 Answer 1


I wanted a similar setup to the one you described. I ended up installing the latest Python version (3.7) using Anaconda. I found it to be the most straightforward to install Python packages and manage environments. For example, to install gdal you just have to run conda install gdal.

This way, I had two Python installations: the one that comes with ArcGIS 10.x (2.7) and the one I downloaded from Anaconda (3.7). To change the Python version I was using in PyCharm, I would just go to File > Settings... > Project: Project Name > Project Interpreter and choose one of the two Python installations depending if I needed ArcPy or if I needed other packages such as gdal.

On an additional note, the best advantage Anaconda probably has is the simplicty it offers to create and manage new environments. With just one command you can create a new environment inside conda to use a specific version of Python and specific versions of packages (e.g. gdal, numpy, scipy). Then, to use this environment from PyCharm you just have to change the interpreter the same way I described above. (All environments are stored in C:\Users\username\Anaconda3\envs if you installed everything in the default folder.)

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.