在storm中,如何指定特定版本的python [英] In storm, how to specify specific version of python

查看:29
本文介绍了在storm中,如何指定特定版本的python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Storm 中运行一个拓扑来调用 python(例如:WordCountTopology),但我遇到了与 python3.5.2 是我服务器上的默认 python 相关的错误(错误是关于旧的/打印命令的新语法).如何指定风暴使用python2.7而不是python3.5?将 python 别名设置为 python2.7 不会改变任何东西.任何帮助表示赞赏.

I'm trying to run a topology in storm that makes calls to python (ex: WordCountTopology) but I encounter errors that are related to the fact that python3.5.2 is the default python on my server (errors are about the old/new syntax of print command). How to specify to storm to use python2.7 instead of python3.5? Setting a python alias to python2.7 does not change anything. Any help appreciated.

推荐答案

我猜你正在使用 ShellSpout/ShellBolt.在constructor中可以指定执行子进程的命令,所以可以显式设置command为python2.7.

I guess you're using ShellSpout / ShellBolt. In constructor you can specify the command to execute subprocess, so you can explicitly set command to python2.7.

例如

  public static class SplitSentence extends ShellBolt implements IRichBolt {

    public SplitSentence() {
      super("python", "splitsentence.py");
    }

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

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

您可以替换放置python2.7的python".所有监督节点都应该有文件到那个地方.

You can replace "python" to which python2.7 is placed. All supervisor nodes should have file to that place.

这篇关于在storm中,如何指定特定版本的python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆