4

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.

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Feb 11, 2019 at 13:34
2
  • Just thinking out aloud. Have they installed ArcPro not in the default install location? Commented 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. Commented Feb 12, 2019 at 9:08

1 Answer 1

2

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
PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
answered Feb 12, 2019 at 16:06
2
  • of course, you'll import os at the top of the script with the arcpy import Commented 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. Commented Feb 15, 2019 at 8:18

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.