I have a script that starts by creating a FileGDB by calling arcpy.CreateFileGDB_management.
It runs without error on my own laptop, but raises an error when my colleagues try to run it outside of ArcGIS Pro.
This is the code I'm trying to run:
import arcpy
arcpy.env.workspace = "C:\\LOCAL\\Project"
home = "C:\\LOCAL\\Project"
GDB = "test.gdb"
arcpy.CreateFileGDB_management(home, GDB)
But it gives the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 20234, in CreateFileGDB
raise e
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 20231, in CreateFileGDB
retval = convertArcObjectToPythonObject(gp.CreateFileGDB_management(*gp_fixargs((out_folder_path, out_name, out_version), True)))
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 498, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
RuntimeError: Object: Error in executing tool
When run from the Python window inside ArcGIS Pro there's no issue, it only happens when it's run from outside.
I've tried to run it in 2 different ways:
- In PyCharm by setting the interpreter to C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe
- Inserting the code one-by-one directly in C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe
I've tested this on 2 different devices, both giving the same error.
The complete script works on my own laptop but I can't seem to get it to work on other devices. It feels like I'm overlooking a setting somewhere.
-
Just thinking out aloud. Have they installed ArcPro not in the default install location?Hornbydd– Hornbydd2019年02月11日 14:24:09 +00:00Commented Feb 11, 2019 at 14:24
-
They did install it in the default install location. I also compared their installation folders to mine (as mine is working) and I can't seem to find a difference. I thought maybe it has something to do with them having a previous installation of Python but I can't seem to find anything about that either.Paul– Paul2019年02月12日 09:08:38 +00:00Commented Feb 12, 2019 at 9:08
1 Answer 1
Since it's on another machine, perhaps it is possible that they don't have a C://LOCAL//Project folder.
Try adding this after you define the string value for home:
import os
if not os.path.exists(home):
os.makedirs(home)
If that doesn't work, try putting r in front of the string quotes:
home = r'C:\\LOCAL\\Project'
Also, if you've already run it from ArcGIS Pro, it could be failing because the GDB already exists. If so, try calling this at the top of the script to allow overwriting:
arcpy.env.overwriteOutput = True
-
of course, you'll import os at the top of the script with the arcpy importflintlockspecial– flintlockspecial2019年02月12日 16:13:32 +00:00Commented Feb 12, 2019 at 16:13
-
I tried this but none of it helped. It just seems so weird to me that I can't do the most basic Arcpy functions outside of ArcPro.Paul– Paul2019年02月15日 08:18:02 +00:00Commented Feb 15, 2019 at 8:18
Explore related questions
See similar questions with these tags.