0

When I run a Python file in Flink CLI using the following code:

python3 word_count.py

I got the error like this:

Traceback (most recent call last):
  File "word_count.py", line 79, in <module>
    word_count()
  File "word_count.py", line 37, in word_count
    t_config = TableConfig()
  File "/usr/local/lib/python3.7/dist-packages/pyflink/table/table_config.py", line 49, in __init__
    gateway = get_gateway()
  File "/usr/local/lib/python3.7/dist-packages/pyflink/java_gateway.py", line 68, in get_gateway
    callback_server_listening_address, callback_server_listening_port)
TypeError: 'JavaPackage' object is not callable

And I changed the way to run this Python file:

./bin/flink run --python3 /opt/flink/examples/python/table/batch/word_count.py

I got another error :

Could not build the program from JAR file.

Use the help option (-h or --help) to get help on the command.
YT Q
  • 31
  • 4

2 Answers2

0

Didn't figure out the first question but solved the second one.

The command within --python3 caused the error.

The official Pyflink command is

./bin/flink run -py word_count.py

Since there is only Python3 in my docker, I soft linked Python3 to Python using :

ln -s /usr/bin/python3 /usr/bin/python 

And then the official Pyflink command works. You can see the completed job through Flink Web UI.

YT Q
  • 31
  • 4
0

The default is to use the python interpreter on the machine to compile pyflink jobs, you can change it through python.client.executable.

Xingbo Huang
  • 363
  • 1
  • 5