无法在Python问题中导入工具箱ArcGIS pro 3.0.3 //www.gamepadva.com/t5/python-questions/unable-to-import-toolbox-arcgis-pro-3-0-3/m-p/1246231#M66449

我是arcgis pro 3.0.3桌面,想分享一个工具箱,里面包含一个python脚本工具,我和同事一起创建的。在我的电脑上,我能够打开,运行和利用这个工具没有任何问题。当我共享工具箱时,我的同事可以将工具箱添加到他的地图项目中,并打开它,但在运行它时得到一个无法打开工具箱的错误。< / P >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!

2023年1月6日星期五23:39:12 GMT NephtaliChavez 2023 - 01 - 06 - t23:39:12z 无法导入工具箱ArcGIS pro 3.0.3 //www.gamepadva.com/t5/python-questions/unable-to-import-toolbox-arcgis-pro-3-0-3/m-p/1246231#M66449

我是arcgis pro 3.0.3桌面,想分享一个工具箱,里面包含一个python脚本工具,我和同事一起创建的。在我的电脑上,我能够打开,运行和利用这个工具没有任何问题。当我共享工具箱时,我的同事可以将工具箱添加到他的地图项目中,并打开它,但在运行它时得到一个无法打开工具箱的错误。< / P >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!

2023年1月6日星期五23:39:12 GMT //www.gamepadva.com/t5/python-questions/unable-to-import-toolbox-arcgis-pro-3-0-3/m-p/1246231#M66449 NephtaliChavez 2023 - 01 - 06 - t23:39:12z
无法导入工具箱ArcGIS pro 3.0.3 //www.gamepadva.com/t5/python-questions/unable-to-import-toolbox-arcgis-pro-3-0-3/m-p/1246237#M66451

所以是用户btroxel有问题吗?

你复制了MRV了吗?

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

 

R_

2023年1月7日星期六00:05:01 GMT //www.gamepadva.com/t5/python-questions/unable-to-import-toolbox-arcgis-pro-3-0-3/m-p/1246237#M66451 RhettZufelt 2023 - 01 - 07 - t00:05:01z
无法导入工具箱ArcGIS pro 3.0.3 //www.gamepadva.com/t5/python-questions/unable-to-import-toolbox-arcgis-pro-3-0-3/m-p/1246248#M66454

是的,他有问题。我能运行得很好。是的,我查过他把它保存在那个位置。该路径是保存在云(oneddrive)上的文件夹,我不确定这是否有问题。 

2023年1月7日星期六02:51:51 GMT //www.gamepadva.com/t5/python-questions/unable-to-import-toolbox-arcgis-pro-3-0-3/m-p/1246248#M66454 NephtaliChavez 2023 - 01 - 07 - t02:51:51z
无法导入工具箱ArcGIS pro 3.0.3 //www.gamepadva.com/t5/python-questions/unable-to-import-toolbox-arcgis-pro-3-0-3/m-p/1246418#M66459

@NephtaliChavez 写道:

该路径是保存在云(onedrive)上的文件夹,我不确定这是否是一个问题。


这和你的运行方式不同吗?它是否适用于您的OneDrive路径?< / P > 2023年1月9日星期一14:05:50 GMT //www.gamepadva.com/t5/python-questions/unable-to-import-toolbox-arcgis-pro-3-0-3/m-p/1246418#M66459 BlakeTerhune 2023 - 01 - 09 - t14:05:50z 无法导入工具箱ArcGIS pro 3.0.3 //www.gamepadva.com/t5/python-questions/unable-to-import-toolbox-arcgis-pro-3-0-3/m-p/1246447#M66462 是的,这就是我想知道的。这条路径对我来说很有效,但可能
不是设置它的最佳方式。关于如何让脚本
引用工具箱,无论它保存在哪里的想法?< BR / >
2023年1月9日星期一15:29:42 GMT //www.gamepadva.com/t5/python-questions/unable-to-import-toolbox-arcgis-pro-3-0-3/m-p/1246447#M66462 NephtaliChavez 2023 - 01 - 09 - t15:29:42z
无法导入工具箱ArcGIS pro 3.0.3 //www.gamepadva.com/t5/python-questions/unable-to-import-toolbox-arcgis-pro-3-0-3/m-p/1246615#M66481

你可以硬编码路径(如果它是一个共享工具箱),或者在你的工具上有一个额外的输入参数,用户可以浏览到工具箱。

2023年1月9日星期一21:14:00 GMT //www.gamepadva.com/t5/python-questions/unable-to-import-toolbox-arcgis-pro-3-0-3/m-p/1246615#M66481 BlakeTerhune 2023 - 01 - 09 - t21:14:00z
无法导入工具箱ArcGIS pro 3.0.3 //www.gamepadva.com/t5/python-questions/unable-to-import-toolbox-arcgis-pro-3-0-3/m-p/1246647#M66483

是的,我相信我需要让它作为参数输入它。我想我觉得很奇怪,工具箱的路径需要指定才能使用它?我觉得在我见过的其他自定义工具或脚本中,没有人为了使用它而确定工具箱在哪里。

2023年1月9日星期一23:51:44 GMT //www.gamepadva.com/t5/python-questions/unable-to-import-toolbox-arcgis-pro-3-0-3/m-p/1246647#M66483 NephtaliChavez 2023 - 01 - 09 - t23:51:44z