4 Replies Latest reply on Jun 25, 2013 1:41 PM by joshjones75

    Unable to import Python module in ArcMap

    philmorefield
      Summary: I can import a Python module in PythonWin or IDLE. I am not able to import the same module using the Python window in ArcMap.

      I'm working with a Python module that handles NetCDF files (netCDF4-0.9.win32-py2.6.exe from http://code.google.com/p/netcdf4-python/downloads/list)

      The installer for this module is a little different than most. For example instead of dumping all of the files into:

      C:\python26\Lib\site-packages\netCDF4

      it just dumps them in the "site-packages" directory. Now, when I try to import the netCDF4 module in PythonWin or IDLE, it works fine, because that directory is part of sys.path so Python knows to look there when you import something.

      But when I do this using the Python window in ArcGIS, I get an error:

      Runtime error <type 'exceptions.ImportError'>: DLL load failed: The specified procedure could not be found.

      Can somebody from ESRI please look into this?
        • Re: Unable to import Python module in ArcMap
          clm42
          The problem is that a separate python 2.6 is installed in the arcmap directory. You need to go into a file and change or add a path to make it work. Im not sure since I am still at 9.3.1 but I know its come up a few times so if you do a search you should be able to find a solution.
          • Re: Unable to import Python module in ArcMap
            bbinckes
            You might try to add the path to the import prior to import.  I have had funky stuff with python and arcgis. 

            My new rule is to install python 2.6 prior to install any arcgis stuff.  I think 2.6 is the flavor for arcgis 10 and you will also need numpy module installed as well.

            ___
            import sys
            sys.path.append("C:\python26\Lib\site-packages\netCDF4")
            import netCDF4
            ...

            -bob
            • Re: Unable to import Python module in ArcMap
              philmorefield
              Re: the two replies so far...

              I installed Python and numpy before ArcGIS. So ArcGIS is using my Python installation instead of the other way around. The path to all the netCDF4 stuff was already in sys.path. Re-appending it did not fix the problem.

              I'm not sure the netCDF4 installer is totally stable, so I'm checking into some stuff there that might resolve this. But it still seems very odd that the module imports correctly outside of the ArcGIS Python window.
              • Re: Unable to import Python module in ArcMap
                joshjones75
                Phil,



                Did you ever figure out what your problem was?  I am having a very similar problem, but I have no extra packages.  I am simply trying to import the arcpy package into the Python window in ArcMap or ArcCatalog , or run any processes that utilize numpy (Raster Calculator for instance), and I will get the error "ImportError: No module named numpy".  I can run/import these same processes/packages in IDLE and they work fine.  I'm not sure what the problem is.


                Thanks in advance for any help.

                -Josh