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",
spatial_reference=arcpy.SpatialReference(4326))
# then do other things
arcpy
script along with thepandas
in the same environment (Esri shipspandas
along with ArcGIS Desktop since version 10.4 if I recall right). However, there have been a few attempts to achieve what you are looking for at notesfromthelifeboat.com/post/arcpy-virtualenv and my.usgs.gov/confluence/display/cdi/…. Btw if you are able to use conda with ArcGIS Pro, it will be somewhat easier