我在学习Storm,我已经安装了zookeeper,storm,python和pyleus。第一步,我从pyleus web复制python脚本作为示例(https://github.com/Yelp/pyleus/tree/aaa423864f953332202832b8fd8404e03d3d74e3)并尝试在暴风服务器中运行它,示例包括以下3个文件: pyleus_topology.yaml,dummy_spout.py和dummy_bolt.py 2 py文件已放入文件夹即“my_first_topology”但是当我在我的VMware服务器(CentOS64位)中运行pyleus build命令时,该命令可以运行20秒然后,我得到以下错误:
[root @ localhost bin] #pyleus build /root/Desktop/CRM_ETL-Project-Storm/my_first_topology/pyleus_topology.yaml pyleus build:错误:[VirtualenvError]无法执行Python module:my_first_topology.dummy_spout。错误: / tmp / tmpZMIXa3 / resources / pyleus_venv / bin / python:没有命名的模块 my_first_topology
我能为它做些什么?我错过了哪些步骤?
脚本供参考 1 GT; pyleus_topology.yaml
name:my_first_topology
拓扑结构:
- spout:
name: my-first-spout
module: my_first_topology.dummy_spout
- bolt:
name: my-first-bolt
module: my_first_topology.dummy_bolt
groupings:
- shuffle_grouping: my-first-spout
2 - ; dummy_spout.py
来自pyleus.storm导入Spout
class DummySpout(Spout):
OUTPUT_FIELDS = ['sentence', 'name']
def next_tuple(self):
self.emit(("This is a sentence.", "spout",))
如果名称 =='主要': DummySpout()。运行()
3> dummy_bolt.py
来自pyleus.storm导入SimpleBolt
class DummyBolt(SimpleBolt):
OUTPUT_FIELDS = ['sentence']
def process_tuple(self, tup):
sentence, name = tup.values
new_sentence = "{0} says, \"{1}\"".format(name, sentence)
self.emit((new_sentence,), anchors=[tup])
如果名称 =='主要': DummyBolt()。运行()
答案 0 :(得分:1)
我认为您的问题是您在内部my_first_topology文件夹中缺少一个名为“__init.py__”的空文件。那个文件使它成为一个python模块。只需创建它就可以设置。