English

Problem: Converting metadata to XLST format using Python causes ArcGIS Desktop to crash or fails with an error

Description

Attempting to convert metadata to XLST format using Python causes ArcGIS Desktop to crash or fails with the following error:

Error: 
000582: Error occurred during execution

Cause

The following are two causes for the conversion to fail:

Scenario 1: Python script crashes unexpectedly

The script is executed in a 64-bit environment or 64-bit background geoprocessing is turned on. This is an expected behavior. Conversion tools in the Metadata toolset are not supported in the 64-bit processing environment.

Scenario 2: Error 000582: Error occurred during execution

Conversion tools are based on C# programming language, and do not run natively in Python. Therefore, a Python script must have the required DLL files to be able to understand the calling of the desired tools.

Solution or Workaround

Use one of the following solution suggested according to the situation involved:

Scenario 1

Turn off 64-Bit background geoprocessing and ensure the script is executed using Python 32-bit version. To check whether the script is running using a 32-bit or 64-bit geoprocessing environment, add the following code snippet in the beginning of the script:

import arcpy
import os, sys, string

#Show 32bit or 64bit Python/Geoprocessing
import ctypes
print "4 == 32bit, 8 == 64bit"
print ctypes.sizeof(ctypes.c_voidp)

Scenario 2

When using the script outside of ArcGIS, referencing the XSLT transformation and metadata importer tool requires the DLL files to be loaded in the script. Follow the instruction to load the DLL files in order for the script to work.
  1. Open Windows Explorer.
  2. Navigate to C:\Program Files\ArcGIS\Desktop10.X\Bin
  3. Copy the following DLL files:
    • GpMetadataFunctions.dll
    • MetadataTranslator.dll.
  4. Navigate to C:\WINDOWS\assembly
  5. Paste the two DLL files into the folder.
  6. Restart the machine and run the script.
Note:
The folder, C:\WINDOWS\assembly is known as the Global Assembly Cache (GAC).

Related Information