Do I need to bounce back and forth between two virtual environments in order to run Pandas and ArcPy in the same script, while ensuring Pandas (or accidental updates to NumPy) doesn't break Arcpy?

I'm getting a new computer, and I want to set up my Python environments correctly from the start. As an example, below is a common script that I normally write/run in PyCharm. (Somehow I've managed to not break ArcPy by running everything in "C:\Python27\ArcGIS10.6" but I know that is wrong, so I am trying to fix it.)

import pandas as pd
import arcpy

myxls = r'C:\Users\name\path\myfile.xlsx'

tab = 'Sheet1'
xl = pd.ExcelFile(pts_in)
df = xl.parse(tab)
# do things here
out_csv = r'C:\Users\name\path\mynewfile.csv'
df.to_csv(out_csv, index=False, encoding='utf-8')

working = r'C:\Users\name\path\myshapefile.shp'
arcpy.MakeXYEventLayer_management(out_csv, "Longitude", "Latitude", "pts_layer",
# then do other things

1 Answer 1


ArcGIS 10.6 comes with pandas by default:

> pip list

cycler (0.10.0)
functools32 (3.2.3.post2)
future (0.15.2)
matplotlib (1.5.2)
mpmath (0.19)
nose (1.3.7)
numpy (1.9.3)
pandas (0.18.1)
pip (9.0.1)
pyparsing (2.1.4)
pyrocopy (0.8.0)
python-dateutil (2.5.3)
pytz (2016.6.1)
pywin32 (224)
requests (2.11.1)
scipy (0.17.0)
setuptools (28.8.0)
six (1.10.0)
sympy (1.0)
virtualenv (16.0.0)
wheel (0.29.0)
xlrd (1.0.0)
xlwt (1.1.2)

So the following will "just work":

import arcpy
import pandas

If you want a simple virtualenv that can use arcpy and pandas but install other stuff without risking messing up your ArcGIS 10.6 python:

pip install virtualenv
virtualenv --system-site-packages C:\<path\to\env\dir>
pip install somerandompackage

Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import arcpy, pandas
>>> import somerandompackage
>>> arcpy
<module 'arcpy' from 'C:\Program Files (x86)\ArcGIS\Desktop10.6\ArcPy\arcpy\__init__.pyc'>
>>> pandas
<module 'pandas' from 'c:\Python27\ArcGIS10.6\lib\site-packages\pandas\__init__.pyc'>
>>> somerandompackage
<module 'somerandompackage' from 'C:\<path\to\env\dir>\lib\site-packages\somerandompackage\__init__.pyc'>

Your Answer

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

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