lcabon258 / PointProjection2Profile_Project

將點資料投影至剖面上。
0 stars 1 forks source link

Modules in the parent directory won't be able to import for the arcgis toolbox and thus causes the error in the ArcGIS Pro #3

Open lcabon258 opened 6 months ago

lcabon258 commented 6 months ago

目前計畫的目錄規劃中,ArcGIS Pro的工具箱 .pyt 會遇到無法匯入位於母資料夾的模組們,並造成錯誤。 使用確認文法功能時顯示的錯誤: CheckSyntaxError

lcabon258 commented 6 months ago

Remove the try and except block in line 9-15 in the .pyt file can make the error show in the AGP.

Import Error

The .pyt seems to execute as a main module in the AGP. Potential solutions includes in the following discussion: 1 How can I do relative imports in Python?](https://stackoverflow.com/questions/72852/how-can-i-do-relative-imports-in-python) 2. How to resolve: attempted relative import with no known parent package [duplicate] 3 PEP 366 – Main module explicit relative imports 4 PEP 302 – New Import Hooks

lcabon258 commented 6 months ago

Modifying the import clauses below:

from .. import gdalio as gio
from .. import ppt

Which doesn't work well. The following error occurs:

Traceback (most recent call last):
  File "<string>", line 9, in <module>
ImportError: attempted relative import with no known parent package
lcabon258 commented 6 months ago

The latest commit should fix the problem. @JasmineWanTingWei Please try the toolbox again.