ArcGIS Pro如何引用自定义Python模块

ArcGIS Pro采用的conda管理不同的Python运行环境,软件安装时会创建一个名叫”arcgispro-py3“的默认环境。

在Python Notebook、Python窗口或ModelBuilder这些有机会应用到Python的地理处理环境中,当需要引用自行编写的自定义Python模块时,可以通过以下两种方式来引用:

方法一:

编辑Program Files > ArcGIS > Pro > bin > Python > envs > arcgispro-py3 > Lib > site-packages > ArcGISPro.pth文件。

在该文件中编辑:

import sys; sys.path.append(r"C:\\CustomScriptsFolder")
其中 C:\\CustomScriptsFolder 为存放自定义Python脚本的目录。

方法二:
直接在Python Notebook、Python窗口或ModelBuilder中的Python脚本中通过代码引用。
myPythonModules = r'C:\\CustomScriptsFolder'
sys.path.append(myPythonModules)
 
posted @ 2024-01-08 08:59  卢伟亮  阅读(2)  评论(0)    收藏  举报