我正在尝试运行一个简单的Pyro示例(taken from this page),这是代码:

import Pyro.core
import Pyro.naming

class JokeGen(Pyro.core.ObjBase):
  def joke(self, name):
    return "Sorry "+name+", I don't know any jokes."

daemon=Pyro.core.Daemon()
ns=Pyro.naming.NameServerLocator().getNS()
daemon.useNameServer(ns)
uri=daemon.connect(JokeGen(),"jokegen")
daemon.requestLoop()


当我使用Python 2.6.5和Python 2.6.6(在Ubuntu 10.04和Debian Squeeze上都尝试过)运行此脚本时,总是出现此错误:

Traceback (most recent call last):
  File "/home/ingo/tools/python/pyroserver.py", line 9, in <module>
    ns=Pyro.naming.NameServerLocator().getNS()
  File "/usr/lib/pymodules/python2.6/Pyro/naming.py", line 176, in getNS
    reply = self.sendSysCommand(NS_SYSCMD_LOCATION,host,port,trace,1,bcaddr)
  File "/usr/lib/pymodules/python2.6/Pyro/naming.py", line 76, in sendSysCommand
    raise Pyro.errors.NamingError("could not find NameServer")
Pyro.errors.NamingError: could not find NameServer


脚本出了什么问题?如何创建该名称服务器?

最佳答案

首先在另一个终端上运行pyro-ns。那就是Pyro对象代理。

关于python - 使用NameServer启动Pyro守护程序时出错:“找不到NameServer”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5933016/

10-14 02:16