在风暴中,如何指定特定版本的python [英] In storm, how to specify specific version of python
问题描述
我正在尝试在风暴中运行一个使调用python的拓扑(例如:WordCountTopology),但是遇到与python3.5.2是服务器上的默认python这一事实有关的错误(错误是关于旧的/print命令的新语法).如何指定要使用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.在构造函数中,您可以指定执行子进程的命令,因此可以将命令显式设置为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.
这篇关于在风暴中,如何指定特定版本的python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!