Book Image

ArcPy and ArcGIS: Geospatial Analysis with Python

Book Image

ArcPy and ArcGIS: Geospatial Analysis with Python

Overview of this book

Table of Contents (19 chapters)
ArcPy and ArcGIS – Geospatial Analysis with Python
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The sys.path.append() method


The sys.path function is a list (did you notice the square brackets in the preceding code output?) and as such can be appended or extended to include new file paths that will point to modules the user wants to import. To avoid the need to adjust sys.path, copy the module into the site-packages folder. When this is not possible, use the sys.path.append() method instead:

>>> sys.path.append("C:\\Projects\\Requests")
>>> sys.path
['', 'C:\\WINDOWS\\SYSTEM32\\python27.zip',
  'C:\\Python27\\ArcGIS10.2\\Dells',
  'C:\\Python27\\ArcGIS10.2\\lib',
..'C:\\Python27\\ArcGIS10.2\\lib\\plat-win',
..'C:\\Python27\\ArcGIS10.2\\lib\\lib-tk',
..'C:\\Python27\\ArcGIS10.2\\Lib\\site-packages\\pythonwin',
..'C:\\Python27\\ArcGIS10.2', ..'C:\\Python27\\ArcGIS10.2\\lib\\site-packages', 'C:\\Program
..Files (x86)\\ArcGIS\\Desktop10.2\\bin', 'C:\\Program Files
..(x86)\\ArcGIS\\Desktop10.2\\arcpy', 'C:\\Program Files
..(x86)\\ArcGIS\\Desktop10.2\\ArcToolbox\\Scripts...