介绍:
我有一个装有 Python 2.7 和 RPyC 的 Linux 机器。此外,我安装了一个 Windows (Server 2008) 盒子,它安装了相同的 Python 版本、RPyC 和 pywin32。Windows box 运行 RPyC classic_server,Linux box 用于运行 RPyC 客户端。通常,我正在构建基础设施以从 Linux 机器远程管理 Active Directory (AD) 服务器。对于 AD 管理,将使用安装在 Windows 机器上的“pyad”模块。
问题:
通常,所有这些捆绑包都按承诺工作。
In [3]: conn = rpyc.classic.connect("10.103.224.44")
In [4]: conn.modules.os.getcwd()
Out[4]: 'C:\\ldap-automation-project\\scripts'
但是当我尝试调用远程“pywin32”或“pyad”时它失败了(pywin32 是一个依赖项)。
In [7]: conn.modules.pywin32
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-7-31ec7f3bb520> in <module>()
----> 1 conn.modules.pywin32
/usr/lib/python2.7/site-packages/rpyc/core/service.pyc in __getattr__(self, name)
119 return self.__cache[name]
120 def __getattr__(self, name):
--> 121 return self[name]
122
123 class SlaveService(Service):
/usr/lib/python2.7/site-packages/rpyc/core/service.pyc in __getitem__(self, name)
116 name = ".".join(name)
117 if name not in self.__cache:
--> 118 self.__cache[name] = self.__getmodule(name)
119 return self.__cache[name]
120 def __getattr__(self, name):
/usr/lib/python2.7/site-packages/rpyc/core/netref.pyc in __call__(_self, *args, **kwargs)
194 def __call__(_self, *args, **kwargs):
195 kwargs = tuple(kwargs.items())
--> 196 return syncreq(_self, consts.HANDLE_CALL, args, kwargs)
197 __call__.__doc__ = doc
198 return __call__
/usr/lib/python2.7/site-packages/rpyc/core/netref.pyc in syncreq(proxy, handler, *args)
69 raise ReferenceError('weakly-referenced object no longer exists')
70 oid = object.__getattribute__(proxy, "____oid__")
---> 71 return conn.sync_request(handler, oid, *args)
72
73 def asyncreq(proxy, handler, *args):
/usr/lib/python2.7/site-packages/rpyc/core/protocol.pyc in sync_request(self, handler, *args)
439 isexc, obj = self._sync_replies.pop(seq)
440 if isexc:
--> 441 raise obj
442 else:
443 return obj
ImportError: No module named pywin32
========= Remote Traceback (1) =========
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\rpyc\core\protocol.py", line 305, in _dispatch_request
res = self._HANDLERS[handler](self, *args)
File "C:\Python27\lib\site-packages\rpyc\core\protocol.py", line 535, in _handle_call
return self._local_objects[oid](*args, **dict(kwargs))
File "C:\Python27\lib\site-packages\rpyc\core\service.py", line 163, in exposed_getmodule
return __import__(name, None, None, "*")
ImportError: No module named pywin32
有任何想法吗?