简体   繁体   English

如何在nifi中执行script python脚本

[英]how to executescript python script in nifi

I want to put rest api output to a file with python script.我想将rest api输出放入带有python脚本的文件中。

在此处输入图片说明 在此处输入图片说明

test1.py - python script test1.py - python 脚本

import urllib.request导入 urllib.request

abc = urllib.request.urlopen(' http://xxxxxxx ') abc = urllib.request.urlopen(' http://xxxxxxx ')

print(abc.read())打印(abc.read())

Python code is fine. Python代码很好。

在此处输入图片说明

but An error occurs in nifi.但是nifi出现错误。

ImportError: No module named request in at line number 1导入错误:第 1 行中没有名为请求的模块

在此处输入图片说明

what should i do?我该怎么办?

What's the problem?有什么问题? Is it a Jython problem?是 Jython 的问题吗? How can I solve this?我该如何解决这个问题?

please help me thank you.请帮助我谢谢。

That is Jython and you cannot use the external packages of the python in general.那就是 Jython,一般情况下你不能使用 python 的外部包。 I'd recommend you to use the ExecuteStreamCommand with the options,我建议您使用带有选项的ExecuteStreamCommand

Command Arguments      /path/to/test1.py
Command Path           /path/to/python

where the python should be installed separately in the NI-FI server. python应该单独安装在NI-FI服务器中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM