[GIS] Installing xlutils alongside xlrd and xlwt in ArcPy install folder to facilitate copying Excel worksheets

arcgis-10.4arcpyexcelinstallation

Whenever possible I avoid installing Python libraries other than those installed with ArcPy by the ArcGIS Desktop 10.x and ArcGIS Pro installs but occasionally I have for ReportLab, gdal, pyodbc and I usually find several ways are suggested and I only get them working after some experimentation.

I would like to be able to copy a worksheet from one Excel (*.xls) spreadsheet, created using TableToExcel in ArcPy, to another Excel (*.xls) spreadsheet (also created by ArcPy), and the only technique that I found that looks promising for doing this is in this answer to Writing to existing workbook using xlwt

That technique commences by importing xlrd, xlwt and xlutils using the re-ordered lines below:

from xlrd import open_workbook
from xlwt import easyxf
from xlutils.copy import copy

When I run them using IDLE from Python 2.7.10 that was installed with ArcGIS 10.4.1 for Desktop I get this error which indicates that xlrd and xlwt are available but xutils is not.

Traceback (most recent call last): File "C:\Fyfe\xutilsTest.py",
line 3, in
from xlutils.copy import copy ImportError: No module named xlutils.copy

This matches what I see when I look in C:\Python27\ArcGIS10.4\Lib\site-packages where xlrd and xlwt folders can be seen but no xlutils.

enter image description here

Is there a simple process that will let me download a folder of Python code for xlutils and copy it into the same folder to make import xlutils just work?

Installing third party python libraries in ArcGIS location gives me some hints about what may need to be done but that Q&A seems to be more understandable by someone who develops using a higher Python:ArcPy ratio than I do.

Best Answer

You can install from pypi using pip:

pip install --user xlutils

http://pythonhosted.org/xlutils/installation.html

If pip.exe is not in your PATH use the full path to to pip.exe or replace pip with python -m pip

Related Question