如何在apachestormshell中使用anacondapython

hujrc8aj  于 2021-06-24  发布在  Storm
关注(0)|答案(1)|浏览(185)

我正在尝试使用shell bolt用python bolt运行apachestorm拓扑。在我的bolt中,我使用的是安装在/home/labuser/anaconda3/bin/python中的spacy库。但是,当我运行拓扑风暴显示错误消息模块没有找到空间。调试之后,我发现storm使用的是位于/usr/bin/python中的Python2.7。
我的问题是下面问题的扩展,在storm中,如何指定python的特定版本
根据上述问题的答案,我尝试使用super(“home/labuser/anaconda3/bin/python”,“splitsencement.py”)创建shell bolt;但storm在/usr/bin/python dir中继续增长2.7。
我需要知道如何告诉storm使用home/labuser/anaconda3/bin/python目录中的python3作为shell螺栓。

inb24sb2

inb24sb21#

事实证明,指定在shell bolt的构造函数中使用哪个python版本才是答案。我最初尝试过这个版本,但由于其他一些构建问题,它失败了。我做了一个新的构建,现在它可以工作了。

public static class SplitSentence extends ShellBolt implements IRichBolt {

    public SplitSentence() {
      super("home/labuser/anaconda3/bin/python", "splitsentence.py");
    }

    @Override
    public void declareOutputFields(OutputFieldsDeclarer declarer) {
      declarer.declare(new Fields("word"));
    }

    @Override
    public Map<String, Object> getComponentConfiguration() {
      return null;
    }
  }

多亏了storm中的这个答案,如何指定python的特定版本
如果您有任何其他问题,请务必阅读http://storm.apache.org/releases/2.0.0-snapshot/multilang-protocol.html

相关问题