No module named numpy

4577
6
10-12-2010 07:18 PM
StacieWolny
New Contributor II
Hi, all -

I've just installed ArcMap 9.3.1 and am trying to use numpy in a Python script called from ArcToolbox, but I get this error: <type 'exceptions.ImportError'>: No module named numpy. 

I know it's installed, and if I bring up a python shell and "import * from numpy" it works fine.

Spatial Statistics tools don't work either, some giving the same numpy error as above, others with variations on this:
<type 'exceptions.ImportError'>: Bad magic number in C:\Program Files (x86)\lib\subprocess.pyc.  Sometimes the error is for random.pyc. 

So far I've tried reinstalling just python and numpy, didn't help, nor did reinstalling all of 9.3.1. I made sure that there are no older versions of python on the machine and either deleted or renamed every ArcMap/ESRI directory I could find, in case an old setting was hanging around.  I'm starting to think that there's a greater problem, as I tried Arc 10 and it was a nightmare, crashing regularly and with missing libraries (functools when trying to use Raster Calculator), when a colleague running the same OS (Windows XP Professional x64) has had none of the same problems with either 9.3.1 or 10.

Any ideas would be greatly appreciated...

~ Stacie
0 Kudos
6 Replies
Luke_Pinner
MVP Regular Contributor
Sounds like you've got some setup/installation issues as you say. Can't help there, but regarding numpy, you could try setting the path to numpy explicitly before importing.

e.g
import sys
sys.path.append(<path to numpy>)
import numpy
0 Kudos
StacieWolny
New Contributor II
Thanks - I'll give it a try. It will at least be a workaround until I figure out the underlying problem.

~ Stacie
0 Kudos
SanthaRubini
New Contributor
Hi Stacie,
I am trying to run OLS for my data and I get the same error <type 'exceptions.ImportError'>: No module named numpy.
could you tell me how did you fix this. also it will be great if yo could tell me how you used numpy in python (the flow of fixing it in steps will be highly useful)

with Thanks,
Ruby


Hi, all -

I've just installed ArcMap 9.3.1 and am trying to use numpy in a Python script called from ArcToolbox, but I get this error: <type 'exceptions.ImportError'>: No module named numpy. 

I know it's installed, and if I bring up a python shell and "import * from numpy" it works fine.

Spatial Statistics tools don't work either, some giving the same numpy error as above, others with variations on this:
<type 'exceptions.ImportError'>: Bad magic number in C:\Program Files (x86)\lib\subprocess.pyc.  Sometimes the error is for random.pyc. 

So far I've tried reinstalling just python and numpy, didn't help, nor did reinstalling all of 9.3.1. I made sure that there are no older versions of python on the machine and either deleted or renamed every ArcMap/ESRI directory I could find, in case an old setting was hanging around.  I'm starting to think that there's a greater problem, as I tried Arc 10 and it was a nightmare, crashing regularly and with missing libraries (functools when trying to use Raster Calculator), when a colleague running the same OS (Windows XP Professional x64) has had none of the same problems with either 9.3.1 or 10.

Any ideas would be greatly appreciated...

~ Stacie
0 Kudos
StacieWolny
New Contributor II
Hi Ruby -

I wish I could tell you exactly what fixed it, other than a tech at ESRI fussed with my machine for so long that I stopped paying attention (very sorry that I didn't at least note the final fix.)  What I do remember is that there were python libraries from an old version of python where they shouldn't have been, like an old distribution that didn't uninstall correctly.  ArcMap was apparently looking in this wrong folder, which existed but didn't have all of the necessary files.  What I can recommend is uninstalling your version of python, then look around on the machine for any python installation files/folders that might not have been cleaned up (maybe do a whole system search to be sure) and delete them.  Also look in your system Environment variables, in case there's a path pointing to a wrong place.  Reboot, then try installing again.

~ Stacie
0 Kudos
seria
by Esri Contributor
Esri Contributor

Please follow the instructions on the following Web Page:

Create a PYTHONPATH variable

http://mattmakesmaps.com/blog/2013/07/10/fixing-arcgis-10-dot-1-python-console-numpy-import-error/

0 Kudos
DanPatterson_Retired
MVP Emeritus

and this thread is 5 years old

0 Kudos