0

I am using PyCharm to run simple pyflink latest 1.13 example (it is only two lines). But the get_gateway() method is not working.

For the interpreter I created virtual environment and use it in my PyCharm project. I also downloaded Java8. I tried many steps to solve the issue but

from pyflink.common.serialization import Encoder
from pyflink.common.typeinfo import Types
from pyflink.datastream import StreamExecutionEnvironment
from pyflink.datastream.connectors import StreamingFileSink
def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.
    env = StreamExecutionEnvironment.get_execution_environment()
    env.set_parallelism(1)
C:\Users\myuser\AppData\Local\Programs\Python\Python38\myvenv\Scripts\python.exe C:/Users/myuser/PycharmProjects/pythonProject3/main.py
Hi, PyCharm
Traceback (most recent call last):
  File "C:/Users/myuser/PycharmProjects/pythonProject3/main.py", line 19, in <module>
    print_hi('PyCharm')
  File "C:/Users/myuser/PycharmProjects/pythonProject3/main.py", line 13, in print_hi
    env = StreamExecutionEnvironment.get_execution_environment()
  File "C:\Users\myuser\AppData\Local\Programs\Python\Python38\myvenv\lib\site-packages\pyflink\datastream\stream_execution_environment.py", line 688, in get_execution_environment
    gateway = get_gateway()
  File "C:\Users\myuser\AppData\Local\Programs\Python\Python38\myvenv\lib\site-packages\pyflink\java_gateway.py", line 62, in get_gateway
    _gateway = launch_gateway()
  File "C:\Users\myuser\AppData\Local\Programs\Python\Python38\myvenv\lib\site-packages\pyflink\java_gateway.py", line 106, in launch_gateway
    p = launch_gateway_server_process(env, args)
  File "C:\Users\myuser\AppData\Local\Programs\Python\Python38\myvenv\lib\site-packages\pyflink\pyflink_gateway_server.py", line 221, in launch_gateway_server_process
    return Popen(command, stdin=PIPE, preexec_fn=preexec_fn, env=env)
  File "C:\Users\myuser\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\myuser\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 1311, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
bad_coder
  • 11,289
  • 20
  • 44
  • 72
dodo
  • 435
  • 2
  • 5
  • 11

1 Answers1

0

See similar question here for description: https://stackoverflow.com/a/71840491/272023

JAVA_HOME was not pointing to a valid Java installation.

John
  • 10,837
  • 17
  • 78
  • 141