All,
I'm having an issue connecting a script i developed in IDLE with a Tool in ArcCatalog. Here is the import statement from the script:
from xlrd import open_workbook
import xlwt
from xlutils.copy import copy
import arcpy
import subprocess
...and so on. The script works fine in IDLE, but the error I get while trying to run the tool in ArcCatalog is "ImportError: No module named xlrd"
I imagine this has something to do with where this library is located on my machine, e.g. it isnt found in the places Arc would want it to be. Here is where I have xlrd, xlwt, and xlutils folders saved on my machine: (I'm running 10.1 btw)
C:\Python27\ArcGISx6410.1\Lib
This obviously differs from where arcpy is saved, but it is the same general location of plenty of the other native python libraries are.
Any thoughts on where I should put these libraries so that Arc will "see" them?
Thanks!
Solved! Go to Solution.
You have two versions on python installed on your box it seems, a 32-bit and 64-bit version of python. You'll need to install the package in both location. By default, desktop uses the 32-bit version, which the default location is: C:\Python27\ArcGIS10.1
You can install the package/modules in the site-package directory:
C:\Python27\ArcGIS10.2\Lib\site-packages
C:\Python27\ArcGISx6410.2\Lib\site-packages
Even better use pip to install your python package for you from pypi site.
Andrew
I did get it to work if I stored the libraries into the same directory as the parent script, but does this have to be the case? Is there a place I can store xlrd/xlwt/xlutils that is not within the parent script directory?
You have two versions on python installed on your box it seems, a 32-bit and 64-bit version of python. You'll need to install the package in both location. By default, desktop uses the 32-bit version, which the default location is: C:\Python27\ArcGIS10.1
You can install the package/modules in the site-package directory:
C:\Python27\ArcGIS10.2\Lib\site-packages
C:\Python27\ArcGISx6410.2\Lib\site-packages
Even better use pip to install your python package for you from pypi site.
Andrew
Thank you for response Andrew. I put those three modules in the "...\site-packages" directory in both the 32 bit and 64 bit versions and the tool was able to "see" them!
I do find it a bit odd that modules are located in multiple locations, but hey if it works it works.
Actually, you can have python libraries or modules in any directory. You just have to add them to the PYTHONPATH so that python can find them. python - Permanently add a directory to PYTHONPATH - Stack Overflow
That's true, but if you put it in the site package folder, then you don't have to mess with that.