Unable to import toolbox ArcGIS pro 3.0.3

911
6
01-06-2023 03:39 PM
NephtaliChavez
New Contributor II

I am arcgis pro 3.0.3 desktop and would like to share a toolbox, that contains a python script tool, I created with a coworker. On my computer, I am able to open, run and utilize this tool without any issues at all. When I share the toolbox, my coworker can add the toolbox to his map project, and open it but gets an error that it is unable to open the toolbox when he runs it.

Monitoring Plots Generator 1
=====================
ParametersBoundary layer     woodland_18048_ExportFeature1
Woodland ID     18048
Boundary Acres     144
Intermediate Ouput Geodatabase     C:\Users\btroxel\OneDrive - American Forest Foundation\Documents - FAMILY FOREST CARBON PROGRAM\Geospatial Library\_MRV cross-regional\Python Scripts\test_properties\scratch.gdb
Final Plot Save GDB     C:\Users\btroxel\OneDrive - American Forest Foundation\Documents - FAMILY FOREST CARBON PROGRAM\Geospatial Library\_MRV cross-regional\Python Scripts\test_properties\test_properties.gdb
Final Plot Projection     GEOGCS["GCS_Assumed_Geographic_1",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
=====================
MessagesStart Time: Wednesday, January 4, 2023 12:20:06 PM
Traceback (most recent call last):
  File "C:\Users\btroxel\OneDrive - American Forest Foundation\Documents - FAMILY FOREST CARBON PROGRAM\Geospatial Library\_MRV cross-regional\Plot_generator\MRV.atbx#MonitoringPlotsGenerator1_MRV.py", line 23, in <module>
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\__init__.py", line 171, in ImportToolbox
    return import_toolbox(input_file, module_name)
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\toolbox_code.py", line 486, in import_toolbox
    toolbox = gp.createObject("Toolbox", tbxfile)
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 389, in createObject
    self._gp.CreateObject(*gp_fixargs(args, True)))
OSError: The toolbox file C:\Users\btroxel\American Forest Foundation\FAMILY FOREST CARBON PROGRAM - Documents\Geospatial Library\_MRV cross-regional\Plot_generator\MRV.atbx was not found.Failed script (null)...
Failed to execute (MonitoringPlotsGenerator1).
Failed at Wednesday, January 4, 2023 12:20:06 PM (Elapsed Time: 0.23 seconds)

Feel free to download the folder containing the python scripts and toolbox. The screenshot also shows that the toolbox does exist on his computer. I will try to summarize the tool as best as I can. 

The MRV plots generator was created to randomly generate between 9-11 plots/points within a boundary that can be of any shape or size (can also be a multi-part polygon). It will take into account the acreage of the boundary and mathematically calculate the initial spacing of the points to try to get to the right number of plots. To further randomize, it will shift and rotate the points by some random amount/angle. It works great on my computer, but I need to be able to share it!

It has some hacky python scripting because I am a novice at this,  but I tried to put in a comments to help describe the process. The mesh points creation, the rotation and shifting of the points is all using tools developed by @DanPatterson_Retired which were huge in making this tool possible. 

Toolbox has an alias, so I know that isn't the issue. The line that brings in the toolbox is

arcpy.ImportToolbox(
    r"{}\American Forest Foundation\FAMILY FOREST CARBON PROGRAM - Documents\Geospatial Library\_MRV cross-regional\Plot_generator\MRV.atbx".format(os.path.expanduser('~')))

I have the expand user bit in there because it is saved on OneDrive and the start of the pathname changes based on the user. This is where I am guessing the problem lies, but I am lost on how to fix it.

Any assistance is appreciated, thank you!

Tags (3)
0 Kudos
6 Replies
RhettZufelt
MVP Frequent Contributor

So is it user btroxel having the issues?

Did you copy the MRV.atbx locally on his computer to the folder:

C:\Users\btroxel\American Forest Foundation\FAMILY FOREST CARBON PROGRAM - Documents\Geospatial Library\_MRV cross-regional\Plot_generator

 

R_

0 Kudos
NephtaliChavez
New Contributor II

Yes, he is having the issue. I can run it just fine. And yes I've checked that he has it saved in that location. That path is to a folder saved on the cloud(onedrive), which I'm not sure if that's an issue. 

0 Kudos
BlakeTerhune
MVP Regular Contributor

@NephtaliChavez wrote:

That path is to a folder saved on the cloud(onedrive), which I'm not sure if that's an issue.


 Is that different from how you run it? Does it work for you with a OneDrive path?

0 Kudos
NephtaliChavez
New Contributor II
Yea that's what I'm wondering. That path works well for me but probably
isn't the best way to set it up. Any idea on how to have the script
reference the toolbox no matter where it is saved?
0 Kudos
BlakeTerhune
MVP Regular Contributor

You could either hard code the path (if it's a shared toolbox) or have an additional input parameter on your tool where the user can browse to the toolbox.

0 Kudos
NephtaliChavez
New Contributor II

Yes, I would need to have it input it as a parameter I believe. I guess I find it strange that the path to the toolbox needs to be specified in order to use it? I feel like in other custom tools or scripts I've seen, nobody ever identifies where the toolbox is in order to use it.

0 Kudos