I have been running my python script that uses arcpy, from Powershell without any problems. But in the middle of a session, I thought to update ArcGIS Pro from 3.0.1 to 3.1 and my script immediately stopped working. I run my script from Powershell using propy (the propy.bat file location is added to my environmental variables). The following error is produced:
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'ArcGIS.Core, Version=13.1.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86'. The system cannot find the file specified.
File name: 'ArcGIS.Core, Version=13.1.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86'
at ArcGIS.Core.Internal.PluginWorkspaceFactoryShim.FinalConstruct(PluginWorkspaceFactoryShim* )
at ATL.CComPolyObject<ArcGIS::Core::Internal::PluginWorkspaceFactoryShim>.FinalConstruct(CComPolyObject<ArcGIS::Core::Internal::PluginWorkspaceFactoryShim>* )
at ATL.CComPolyObject<ArcGIS::Core::Internal::PluginWorkspaceFactoryShim>.CreateInstance(IUnknown* pUnkOuter, CComPolyObject<ArcGIS::Core::Internal::PluginWorkspaceFactoryShim>** pp)
at ArcGIS.Core.Internal.PluginWorkspaceFactoryShim.CreateInstance(IAddInRecord* pAddinRecord, IUnknown* controllingUnknown, IUnknown** ppPluginWorkspaceFactory)
at PluginFactory.CreateObject(PluginFactory* , IAddInRecord* pAddinRecord, IUnknown* pUnkOuter, IUnknown** ppPluginWorkspaceFactory)
This only happens when a method that takes a file name or location as a parameter is run. For instance, the following doesn't produce an error:
arcpy.env.overwriteOutput = True // no error
But this does:
arcpy.env.workspace = "location of gdb" //error
and so does this:
arcpy.Exists("location of gdb that exists") //error
but the following doesn't produce an error; just prints False.
arcpy.Exists("") //no error
I've tried restarting my Windows and rechecking environmental variables in Systems Settings. The same commands run fine from within ArcGIS Pro's python window. As far as I could tell, this started happening after I upgraded to Pro 3.1
Anyone have any idea what could be wrong here? I need to use propy or python to run my script from the shell.
Both python or propy commands from shell give same error
This issue is addressed in Pro 3.1.3, which was released today. Let us know if you run into anything else.
Cheers, Shaun
Hi Shaun
The bug 000157823 still occurs in Pro 3.1.3 if you clone the default arcgispro-py3 environment and use the clone as the active environment. We've already contacted Esri support.
Thanks for the report, this was overlooked in the patch installation, as cloning will follow the conda metadata and ignore local changes to the files registered against conda. There are a couple of things you can do until this is patched more completely:
1. Locate the <arcgispro-py3>\Lib\site-packages\arcgisscripting\_arcgisscripting.pyd file from the default environment, and copy that into your custom environment.
2. We are currently testing a custom package to also address this. You can install it by first activating your custom environment, then running `conda install esri/label/prerelease::arcpy=3.1`. If the testing on this package looks good, we will promote it and the command will simplify to `conda upgrade arcpy`.
The updated arcpy package has completed its testing and is now available by running `conda install arcpy=3.1` from an affected environment. We will get this into the next available Pro 3.1 patch.
The errors that i encountered when running a python script (either from .Net out of process, or from a Windows command prompt) were caused by Plugin Datasource extensions that i had installed at one time. It appears that arcpy is now initializing Plugin datasource extensions (to support custom data imports) in 3.1 even if those Plugins are not used in the script. i was able to fix my problem by deleting any plugins with a ".esriPlugin" file extension in my Documents\ArcGIS\Addins folder. After i removed those plugin extensions my python scripts worked without any problems and without throwing any 'dll file not found' errors. The dev team is working on a fix for this specific issue.
Just confirming that removing XTools Pro (installed by default with all instances of AGP in my agency) resolved the problem for me.
Is there a bug number so we can track this?
Thanks @KevinCheriyan for bringing up this issue, and to @Wolf and @EvanThoms for some insight. I was experiencing the same issue and removing XTools Pro solved it. I'd also be interested in seeing a bug number if available, to forward to the GIS community in my organization.
@JoshuaFlickinger The errors that i encountered were caused by an issue with arcpy when Plugin Datasources were installed unrelated to interference from XTools Pro. My issue has been addressed. As for the issue with XTools Pro interfering with arcpy you need to check with @ShaunWalbridge . My home is the ArcGIS Pro SDK so unfortunately i know little about the issue at hand.
Fair enough. I was getting the same error as OP, so assumed it was related. @ShaunWalbridge do you have any additional insight as to why XTools is interfering with arcpy? I wasn't a huge XTools Pro user to begin with, so removing it isn't a big deal for me. But some of my colleagues will be less thrilled with the guidance 'just remove XTools'.
If I'm understanding you correctly, you're saying the original issue with Plugin Datasources and arcpy is fixed in a development build? Do you have an estimate when this will be released to customers? Will it be in the next service patch for 3.1? It doesn't appear to be fixed in service patch 2