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 ArcPro 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 Feb 11 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 Feb 12 at 9:08
2

Since it's on another machine, is it possible 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 ArcPro, 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 import – flintlockspecial Feb 12 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 Feb 15 at 8:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.