Select to view content in your preferred language

Python Errors in IDLE when processing metadata

4940
11
10-20-2010 10:21 AM
EricSonger
Occasional Contributor
All, I have a script that work when copied and pasted into a python window in ArcCatalog, but it will not run from an IDLE window.  It throws the following error.  Any ideas why?

Traceback (most recent call last):
  File "C:\Python26\ArcGIS10.0\Scripts\xml_export_all.py", line 37, in <module>
    arcpy.ExportMetadata_conversion (source, translator, target)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\conversion.py", line 349, in ExportMetadata
    raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000816: The tool is not valid.
Failed to execute (ExportMetadata).
11 Replies
AletaVienneau
Esri Contributor
This is a known issue for ArcGIS 10: NIM058011. The metadata geoprocessing tools are written in C#. If you add GpMetadataFunctions.dll and MetadataTranslator.dll to the Global Assembly Cache (GAC) the script will run successfully outside of ArcGIS. This issue affects all of the metadata geoprocessing tools, not just Export Metadata.

NOTE: this issue has nothing to do with Map Automation, and probably belongs in a general geoprocessing forum.
EricSonger
Occasional Contributor
This is a known issue for ArcGIS 10: NIM058011. The metadata geoprocessing tools are written in C#. If you add GpMetadataFunctions.dll and MetadataTranslator.dll to the Global Assembly Cache (GAC) the script will run successfully outside of ArcGIS. This issue affects all of the metadata geoprocessing tools, not just Export Metadata.

NOTE: this issue has nothing to do with Map Automation, and probably belongs in a general geoprocessing forum.


Cool!  Thanks.
0 Kudos
RhettZufelt
MVP Notable Contributor
This is a known issue for ArcGIS 10: NIM058011. The metadata geoprocessing tools are written in C#. If you add GpMetadataFunctions.dll and MetadataTranslator.dll to the Global Assembly Cache (GAC) the script will run successfully outside of ArcGIS. This issue affects all of the metadata geoprocessing tools, not just Export Metadata.

NOTE: this issue has nothing to do with Map Automation, and probably belongs in a general geoprocessing forum.



So, since the only reference to that bug number is within other bugs, and none of them explain the "workaround", they just say to add the two dll's to the GAC.

Would be really nice if there was some post somewhere, or directions of how to do such a thing.

R_

Professional ESRI beta tester
0 Kudos
BrynEnright
Emerging Contributor
I was able to fix the problem by installing .NET Framework 2.0 SDK and adding the .dlls to the GAC using gacutil.exe /i

"C:\Program Files\Microsoft.NET\SDK\v2.0\Bin\gacutil.exe" /i "C:\Program Files\ArcGIS\Desktop10.0\Bin\GpMetadataFunctions.dll"
"C:\Program Files\Microsoft.NET\SDK\v2.0\Bin\gacutil.exe" /i "C:\Program Files\ArcGIS\Desktop10.0\Bin\MetadataTranslator.dll"
danbecker
Frequent Contributor
I was able to fix the problem by installing .NET Framework 2.0 SDK and adding the .dlls to the GAC using gacutil.exe /i

"C:\Program Files\Microsoft.NET\SDK\v2.0\Bin\gacutil.exe" /i "C:\Program Files\ArcGIS\Desktop10.0\Bin\GpMetadataFunctions.dll"
"C:\Program Files\Microsoft.NET\SDK\v2.0\Bin\gacutil.exe" /i "C:\Program Files\ArcGIS\Desktop10.0\Bin\MetadataTranslator.dll"


thanks for the info!

I have an 'export metadata' python script written using 9.3 module and when running it on a ArcGIS 10.0 box it would always cause python to crash.

Installed .NET SDK then added the above 2 .dll's to the GAC and the script works perfectly now...just had to change all the ref's from 9.3 tools/meta translators to the v10 paths and all is well. Sure wish the install dir's were the same with v9.3 and v10; sure makes using old scripts on v10 a hassle.

thanks again
GroundHogg
Emerging Contributor
thanks for the info!

I have an 'export metadata' python script written using 9.3 module and when running it on a ArcGIS 10.0 box it would always cause python to crash.

Installed .NET SDK then added the above 2 .dll's to the GAC and the script works perfectly now...just had to change all the ref's from 9.3 tools/meta translators to the v10 paths and all is well. Sure wish the install dir's were the same with v9.3 and v10; sure makes using old scripts on v10 a hassle.

thanks again


I have this problem as well, but I cannot get the MetadataTransaltor.dll to register with the GAC utility.

Without that dll I can still export the metadata but the tool comes up with errors in the box, eventually it allows the metadata to be exported, but you have no options.  I had installed the updates, but did a repair install today.

I was thinking perhaps the dll was corrupted and so maybe a repair might fix it, but no luck so far.

------------

Installed Service pack 2, still get error with metdata export...
0 Kudos
RhettZufelt
MVP Notable Contributor
Interesting that ESRI never did reply to this thread.

Here is the info I got from ESRI tech support:

With regards to the steps you referred to, I was able to find the details from a previous support incident.  Apparently, all of the tools in the Metadata_conversion toolbox are based on C# and will not work outside of ArcMap in a python environment, unless the following dll's are added to the Group Assembly Cache (GAC):

1. Open Windows file explorer
2. Navigate to C:\WINDOWS\assembly
3. Open another window with explorer
4. Navigate to C:\Program Files\ArcGIS\Desktop10.0\Bin 5. Select the GpMetadataFunctions.dll and MetadataTranslator.dll and drag and drop them into the GAC.

However, it didn't work.

Don't remember what I did as it was a while back.  Do remember that I did a Google search and found a link that listed two ways to do it.  One was with the utility, and didn't work, the other did.

R_

Professional ESRI beta tester
AletaVienneau
Esri Contributor
Aside from the method you describe, the other way to add a dll to the GAC is to use the gacutil.exe utility that is available from Microsoft. An example of how to use this method is provided in one of the above posts in this forum. That utility is available with different Microsoft products and toolkits. I have it through Visual Studio. You might want to check the Microsoft site to see if there are other ways to get it -- I don't know what they are.
MichaelRich
Occasional Contributor
thanks for the info!

I have an 'export metadata' python script written using 9.3 module and ....



Is it possible to share your export metadata python script?  I'm heading down this path and need something to export HTML.  Thanks, Mike
0 Kudos