【发布时间】:2013-06-19 01:05:12
【问题描述】:
经过几个小时的调试和反复试验,我发现导入两个独立的 Python 模块会导致其中一个函数停止工作。
import arcpy
# works
sde_conn = arcpy.ArcSDESQLExecute(r"C:\temp\test.sde")
然而:
import arcpy
import rtree
# fails
sde_conn = arcpy.ArcSDESQLExecute(r"C:\temp\test.sde")
这两个 Python 模块是 rtree 和 ESRI 的 arcpy,这两个模块我都在 Windows 上运行(在 Windows 7 和 Windows Server 2008 R2 以及 32 位和 64 位 Python 安装上都会出现此问题)。
我logged the issue,但我想知道一个模块破坏另一个模块的功能的可能原因是什么?
我快速检查了全局变量,并修改了系统路径。两者都依赖于 DLL。
还有哪些其他因素可能造成影响?
【问题讨论】:
-
当您执行
from rtree import *和from arcpy import *并且存在冲突的函数名称时会发生这种情况 -
Python 作为一种动态语言,模块可能会以多种方式表现不佳并破坏其他内容。猴子补丁内置或标准模块是破坏其他模块的好选择。
标签: python python-import python-module