【发布时间】:2019-05-13 13:26:29
【问题描述】:
我在 python 2.7 中遇到了这个奇怪的导入问题
我的应用程序在一个目录中,该目录有一些子目录和更多 python 应用程序同时运行,使用 Pyro 名称服务器相互通信。
当我运行我的一个应用程序时,它在调用其中一个子方法时在导入时崩溃。
这是一个例外:
Traceback (most recent call last):
File "ps_logic.py", line 15840, in <module>
ps_logic = PSLogic(pyro_objects, cfg_handler, status_distributor, voip_processing)
File "ps_logic.py", line 590, in __init__
self.smarthopper_initial_check()
File "ps_logic.py", line 12824, in smarthopper_initial_check
counters_compared = self.smarthopper_maintenance_action()
File "ps_logic.py", line 12928, in smarthopper_maintenance_action
status = self.smart_hopper_logic.status_get()
File "/home/app_core/flexcore/003-480/ps_logic/smart_devices_logic.py", line 203, in status_get
return SmartStatusAugmented(self.smart_obj.queue_status_get(), self.smart_obj)
File "/usr/lib/python2.7/site-packages/Pyro/core.py", line 381, in __call__
return self.__send(self.__name, args, kwargs)
File "/usr/lib/python2.7/site-packages/Pyro/core.py", line 456, in _invokePYRO
return self.adapter.remoteInvocation(name, Pyro.constants.RIF_VarargsAndKeywords, vargs, kargs)
File "/usr/lib/python2.7/site-packages/Pyro/protocol.py", line 497, in remoteInvocation
return self._remoteInvocation(method, flags, *args)
File "/usr/lib/python2.7/site-packages/Pyro/protocol.py", line 536, in _remoteInvocation
answer = pickle.loads(answer)
ImportError: No module named drivers.smart.smart_common_const
它明确表示它无法导入 drivers.smart.smart_common_const 但问题是,我的代码中没有那行。
如果我尝试查找该行在哪个文件中(因为我已经在某些文件中修复了它),它什么也没找到:
app_core@003-481 ~/flexcore/003-480 $ grep -R "from drivers.smart.smart_common_const import" .
./drivers/.svn/pristine/23/23e13acbf9e604f179d4625e18b2b992116a98a1.svn-base:from drivers.smart.smart_common_const import *
./drivers/.svn/pristine/65/65655973d3c70a16cc982db59db8f2989366524b.svn-base:from drivers.smart.smart_common_const import *
./drivers/.svn/pristine/3b/3ba2e2518e64db9188b63247b763926544bddd90.svn-base:from drivers.smart.smart_common_const import *
app_core@003-481 ~/flexcore/003-480 $
但 svn 文件。
我一直在使用-v 选项运行我的python 应用程序,以找出它试图从该文件导入的位置。但是在该异常之前它没有返回任何调试行,所以我猜它是以前导入的东西,或者如果导入失败则什么也不显示。
我还删除了所有*.pyc 文件并重新启动机器以确保内存中没有留下注释,但问题仍然存在。
还有其他方法可以找出问题所在吗?我开始绝望了..
【问题讨论】:
标签: python-2.7 python-import pyro