python – Pyro4:找不到名称服务器
发布时间:2020-12-30 11:37:28 所属栏目:Python 来源:互联网
导读:我是 Python和Pyro4的新手.所以我尝试按照此页面 Pyro – Python Remote Objects – 4.41的第二个示例,但是当我运行服务器时抛出此异常: Traceback (most recent call last): File greeting-server.py, line 10, in module ns = Pyro4.locateNS()
我是 Python和Pyro4的新手.所以我尝试按照此页面 Pyro – Python Remote Objects – 4.41的第二个示例,但是当我运行服务器时抛出此异常: Traceback (most recent call last): File "greeting-server.py",line 10,in <module> ns = Pyro4.locateNS() # find the name server File "/usr/lib/python2.7/dist-packages/Pyro4/naming.py",line 344,in locateNS raise e Pyro4.errors.NamingError: Failed to locate the nameserver 代码服务器: # saved as greeting-server.py import Pyro4 class GreetingMaker(object): def get_fortune(self,name): return "Hello,{0}. Here is your fortune message:n" "Tomorrow's lucky number is 12345678.".format(name) daemon = Pyro4.Daemon() # make a Pyro daemon ns = Pyro4.locateNS() # find the name server uri = daemon.register(GreetingMaker) # register the greeting maker as a Pyro object ns.register("example.greeting",uri) # register the object with a name in the name server print("Ready.") daemon.requestLoop() # start the event loop of the server to wait for calls 首先在另一个终端运行pyro-ns: $pyro-ns *** Pyro Name Server *** Name server listening on: ('0.0.0.0',9090) WARNING: daemon bound on hostname that resolves to loopback address 127.0.x.x URI is: PYRO://127.0.1.1:9090/7f0001011d2a21ca9fb63702dd216e1143 URI written to: /home/guille/Documents/pyro examples/Pyro4-master/examples/banks/Pyro_NS_URI Name Server started. 备注:我在Debian 8上工作,我安装了: > sudo apt-get install pyro4 运行这个例子 也许我错过了什么.任何想法为什么这不起作用,或者我做错了什么? 解决方法这项工作对我来说:首先在另一个终端运行python -m Pyro4.naming: Not starting broadcast server for localhost. NS running on localhost:9090 (127.0.0.1) URI = PYRO:Pyro.NameServer@localhost:9090 而不是pyro-ns我之前为pyro4做过,因为你看到这个程序改变了 (编辑:甘南站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- AIX上的Python:我的选择是什么?
- python – 逐行文件处理,for-loop vs with
- python – ElementTree find()/ findall()找不到带命名空间
- python – 使用lxml.html提取文本
- 具有上下文变量参数的Django自定义模板标记
- Python绘图:如何使matplotlib.pyplot停止强制我的标记的样
- Mercurial自动部署
- python – 将日期列和时间列合并到datetime列
- python exceptions.UnicodeDecodeError:’ascii’编解码器
- 在Python的Cmd.cmd中完成filename tab-completion
推荐文章
站长推荐
- python – 如何在Linux上打包Kivy IOS应用程序?
- 如何获取numpy.random.choice的索引? – Python
- 在Python Celery中,如何在连续的工作调用中持久保
- 使用带有嵌套查询的python MySQLDB SScursor
- 有时PyDev不会将.py文件识别为python源文件
- python – Keras LSTM输入维度设置
- Python统计python文件中代码,注释及空白对应的行
- 是否有一种标准方法来声明不支持旧的python版本?
- python – Google App Engine中模型的默认值
- 在Django中使用python-social-auth和电子邮件注册
热点阅读