Subject: Marine Geospatial Ecology Tools (MGET) help
Text archives
- From: Jason Roberts <>
- To: "Zehnder, Rebekah" <>
- Cc: "" <>
- Subject: RE: [mget-help] Error while running MGET related to Python installation
- Date: Wed, 2 Dec 2015 15:39:19 +0000
- Accept-language: en-US
- Authentication-results: spf=none (sender IP is ) ;
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:23
Hi Rebekah,
Thanks for your interest in MGET and for reporting this problem. The short story is that you have installed ArcGIS 64-bit Background Geoprocessing, and that MGET is not compatible with it, and even though you do not appear to be executing the tool in the “background” MGET is still failing, but I think I have a solution to that problem. Here is the longer story:
When you install 64-bit Background Geoprocessing, ArcGIS installs a 64-bit version of Python in C:\Python27\ArcGISx6410.3, which lives beside the 32-bit version that it installed to C:\Python27\ArcGIS10.3. When you install MGET, the installer prompts you to choose among the 32-bit Python installations that you want to install MGET to; it will offer C:\Python27\ArcGIS10.3 as a choice (and you picked that) but not C:\Python27\ArcGISx6410.3. Then, if you run tools in the “foreground”, ArcGIS uses the 32-bit Python interpreter that is in C:\Python27\ArcGIS10.3 and can access MGET. This 32-bit interpreter executes within the ArcGIS process itself, typically ArcMap.exe or ArcCatalog.exe. Because MGET is installed with the 32-bit Python, the MGET code can be successfully access from it. When you run tools in the “background”, ArcGIS creates a 64-bit python.exe “child process” and runs the 64-bit interpreter there.
Now what actually happened in your situation below is pretty complicated. In the very beginning, before you manually copied MGET’s files to C:\Python27\ArcGISx6410.3, I believe this happened:
1. You executed the Interpolate No Data Cells tool as a “foreground” geoprocessing task.
2. ArcGIS loaded the 32-bit Python interpreter and began executing MGET, starting with C:\Program Files\GeoEco\ArcGISToolbox\Scripts\InterpolatorInpaintArcGISRaster.py.
3. The MGET tool executed normally until it came the point that it needed to execute MATLAB. Because MATLAB and ArcGIS both happen to utilize an open-source library called xerces-c but compile their own versions that are incompatible, it is not possible to load MATLAB and ArcGIS binary programs into the same process (this is called a “DLL Hell” problem). To work around that, MGET has to execute all MATLAB code in a child python.exe process. In preparation for this, MGET asked Windows for the program that is registered as the default handler for .py files. The ArcGIS 64-bit Background Geoprocessing installer, which was the most recent program to install a version of Python, registered the 64-bit C:\Python27\ArcGISx6410.3\python.exe as the default handler.
4. MGET then used C:\Python27\ArcGISx6410.3\python.exe to execute C:\Python27\ArcGIS10.3\lib\site-packages\GeoEco\Datasets\InpaintGrid.py. This is where things started to go wrong.
5. InpaintGrid.py tried to import GeoEco.Internationalization. Because MGET was not installed to C:\Python27\ArcGISx6410.3\lib\site-packages\, this failed with ImportError: No module named GeoEco.Internationalization.
To try to work around that problem, you copied C:\Python27\ArcGIS10.3\lib\site-packages\GeoEco to C:\Python27\ArcGISx6410.3\lib\site-packages\GeoEco. That got things a little further along, but then it failed when InpaintedGrid.py, running in the 64-bit Python installation, tried to import GeoEco.MetadataUtils which is implemented in C and compiled as a Python extension module. On Windows, Python extension modules are actually DLLs, even though they have the file extension .pyd. Windows then complained that it could not load a 32-bit DLL into the 64-bit python.exe process. (It is not possible to mix 32-bit and 64-bit programs in this way.) This is what the ImportError: DLL load failed: %1 is not a valid Win32 application. means.
Does all that sound correct, as best as you can tell?
If so, I think the solution is this: The problem is in step 3. MGET should not ask Windows for the default handler for .py files. Instead, it should use the python.exe for the installation of Python that is currently executing, which is the 32-bit Python interpreter when running in the foreground. I have prepared a patched file that does this. Could you please try this:
1. Close all ArcGIS programs.
2. Delete the C:\Python27\ArcGISx6410.3\lib\site-packages\GeoEco directory and C:\Python27\ArcGISx6410.3\lib\site-packages\GeoEco\_GeoEcoArcGISHelper.pyd file that you copied.
3. Save the attached file to C:\Python27\ArcGIS10.3\lib\site-packages\GeoEco\DataManagement, overwriting the file that is there. This will fix what MGET does in step 3 above.
4. Retry the Interpolate No Data Cells tool, exactly as you did before. Let me know what happens.
The tool should work. It will still not be able to execute as a background task. If you try that, MGET should fail with ImportError: No module named _GeoEcoArcGISHelper, and, sadly, there is no way to solve that until we are able to produce a 64-bit version of MGET. But MGET should still work in foreground mode even though you have 64-bit Background Geoprocessing installed.
Thanks,
Jason
From: [mailto:]
On Behalf Of Zehnder, Rebekah
Hi. I just installed MGET and am getting the same error when trying to run “Interpolate No Data Cells” as in this message: https://lists.nicholas.duke.edu/sympa/arc/mget-help/2014-06/msg00001.html.
I have ArcGIS 10.3, Python 2.7.8, and Matlab Component Runtime 7.7.
After reading your response to the message above, I checked my python installations and noticed that GeoEco was installed in ArcGIS10.3 but not in ArcGISx6410.3, so I tried copying _GeoEcoArcGISHelper.pyd and the GeoEco directory into ArcGISx6410.3\Lib\site-packages. I ran the tool again, and got a different error:
Executing: InterpolatorInpaintArcGISRaster sandtest2.tif K:\Data\gSSURGO\sandtest2_inpaint1.img Del2a # false Start Time: Tue Dec 01 14:23:56 2015 Running script InterpolatorInpaintArcGISRaster... python.exe: Traceback (most recent call last): python.exe: File "C:\Python27\ArcGIS10.3\lib\site-packages\GeoEco\Datasets\InpaintGrid.py", line 128, in <module> python.exe: main() python.exe: File "C:\Python27\ArcGIS10.3\lib\site-packages\GeoEco\Datasets\InpaintGrid.py", line 30, in main python.exe: Logger.Initialize() python.exe: File "C:\Python27\ArcGISx6410.3\lib\site-packages\GeoEco\Logging.py", line 253, in Initialize python.exe: cls.__doc__.Obj.ValidateMethodInvocation() python.exe: File "C:\Python27\ArcGISx6410.3\lib\site-packages\GeoEco\Metadata.py", line 468, in ValidateMethodInvocation python.exe: import GeoEco.MetadataUtils python.exe: ImportError: DLL load failed: %1 is not a valid Win32 application. RuntimeError: python.exe returned exit code 1, indicating failure. The following consequences resulted from the original error: Execution of C:\Python27\ArcGISx6410.3\python.exe failed. Failed script InterpolatorInpaintArcGISRaster...
Traceback (most recent call last): File "C:\Program Files\GeoEco\ArcGISToolbox\Scripts\InterpolatorInpaintArcGISRaster.py", line 5, in <module> ExecuteMethodFromCommandLineAsArcGISTool('GeoEco.SpatialAnalysis.Interpolation', 'Interpolator', 'InpaintArcGISRaster') File "C:\Python27\ArcGIS10.3\lib\site-packages\GeoEco\ArcGISScripts.py", line 210, in ExecuteMethodFromCommandLineAsArcGISTool exec sourceCode in globals(), locals() File "<string>", line 1, in <module> File "C:\Python27\ArcGIS10.3\lib\site-packages\GeoEco\SpatialAnalysis\Interpolation.py", line 726, in InpaintArcGISRaster ArcGISWorkspace(os.path.dirname(outputRaster), ArcGISRaster, pathCreationExpressions=[os.path.basename(outputRaster)]).ImportDatasets([InpaintedGrid(ArcGISRasterBand.ConstructFromArcGISPath(inputRaster), method, maxHoleSize, xEdgesWrap)], {False: u'Add', True: u'Replace'}[overwriteExisting], reportProgress=False) File "C:\Python27\ArcGIS10.3\lib\site-packages\GeoEco\Datasets\__init__.py", line 820, in ImportDatasets self._ImportDatasets(datasets, mode.lower(), reportProgress, options) File "C:\Python27\ArcGIS10.3\lib\site-packages\GeoEco\Datasets\Collections.py", line 694, in _ImportDatasets self._ImportDatasetsToPath(pathComponentsForPath[path], datasetsForPath[path], mode, progressReporter, options) File "C:\Python27\ArcGIS10.3\lib\site-packages\GeoEco\Datasets\ArcGIS.py", line 609, in _ImportDatasetsToPath self.DatasetType._ImportDatasetsToPath(os.path.join(self.Path, *pathComponents), sourceDatasets, mode, progressReporter, options) File "C:\Python27\ArcGIS10.3\lib\site-packages\GeoEco\Datasets\ArcGIS.py", line 1121, in _ImportDatasetsToPath GDALDataset._ImportDatasetsToPath(path, sourceDatasets, mode, None, {'useArcGISSpatialReference': True, 'useUnscaledData': useUnscaledData, 'calculateStatistics': False, 'blockSize': blockSize}) File "C:\Python27\ArcGIS10.3\lib\site-packages\GeoEco\Datasets\GDAL.py", line 1073, in _ImportDatasetsToPath data = "sourceDatasets[i].Data[rowsCopied:rowsCopied+rowsToCopy," :] File "C:\Python27\ArcGIS10.3\lib\site-packages\GeoEco\Datasets\__init__.py", line 3670, in __getitem__ return getattr(self._Grid(), self._GetMethod)(key) File "C:\Python27\ArcGIS10.3\lib\site-packages\GeoEco\Datasets\__init__.py", line 3310, in _GetUnscaledDataAsArray data, actualNoDataValue = self._ReadNumpyArray(reorderedSliceList) File "C:\Python27\ArcGIS10.3\lib\site-packages\GeoEco\Datasets\Virtual.py", line 3379, in _ReadNumpyArray maxRunTime=None) File "C:\Python27\ArcGIS10.3\lib\site-packages\GeoEco\DataManagement\Processes.py", line 575, in ExecuteProgram process.Execute() File "C:\Python27\ArcGIS10.3\lib\site-packages\GeoEco\DataManagement\Processes.py", line 498, in Execute Logger.RaiseException(RuntimeError(_(u'%(name)s returned exit code %(code)i, indicating failure.') % {u'name' : programName, u'code' : self.ExitCode})) File "C:\Python27\ArcGIS10.3\lib\site-packages\GeoEco\Logging.py", line 104, in RaiseException raise exception RuntimeError: python.exe returned exit code 1, indicating failure.
Failed to execute (InterpolatorInpaintArcGISRaster). Failed at Tue Dec 01 14:23:57 2015 (Elapsed Time: 0.83 seconds)
Could you please help me figure out how to resolve this?
Thanks, Rebekah Zehnder
To unsubscribe from this list, visit: https://lists.nicholas.duke.edu/sympa/ca/initiate_unsubscribe/mget-help/jason.roberts%40duke.edu |
Attachment:
Processes.py
Description: Processes.py
- [mget-help] Error while running MGET related to Python installation, Zehnder, Rebekah, 12/01/2015
- RE: [mget-help] Error while running MGET related to Python installation, Jason Roberts, 12/02/2015
- RE: [mget-help] Error while running MGET related to Python installation, Zehnder, Rebekah, 12/02/2015
- RE: [mget-help] Error while running MGET related to Python installation, Jason Roberts, 12/02/2015
Archive powered by MHonArc 2.6.19.