0

I want to put rest api output to a file with python script.

enter image description here enter image description here

test1.py - python script

import urllib.request

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

print(abc.read())

Python code is fine.

enter image description here

but An error occurs in nifi.

ImportError: No module named request in at line number 1

enter image description here

what should i do?

What's the problem? Is it a Jython problem? How can I solve this?

please help me thank you.

1 Answer 1

1

That is Jython and you cannot use the external packages of the python in general. I'd recommend you to use the ExecuteStreamCommand with the options,

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

where the python should be installed separately in the NI-FI server.

Sign up to request clarification or add additional context in comments.

5 Comments

thank you sir!! Where can I find the information you said?
Lamanus #Lamanus @Lamanus@Lamanus and can you recommend a processor flow? (rest api - python script -> file)
hm.. if you want the result will be out through the flowfile, then you have to use groovy script or jython. Or, python stdout can be taken into the flowfile. If you want to use rest api then why do you need the python process?
답변 감사합니다.. 사실 제가 그런 스크립트 언어를 (그루비랑 자이썬 등) 잘몰라요... 그냥 인터넷 검색했을때.. 파이썬 스크립트가 잘 나와서요 그래서 프로세서를 제너레이트플로우파일(파일만들기?) -> 익스큐트스트림커맨드(스크립트실행시키기?) -> 풋파일로 바꿔보려고합니다 ^^
Lamanus #Lamanus @Lamanus@Lamanu 의미는 정확히 파악하지 못했지만 generateFlowFile -> executeStreamCommand -> putFile로 rest api 데이터를 받아서 파일로 내리는것을 성공했습니다 감사합니다 !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.