0

当我使用以下代码在 Flink CLI 中运行 Python 文件时:

python3 word_count.py

我得到这样的错误:

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

我改变了运行这个 Python 文件的方式:

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

我得到另一个错误:

Could not build the program from JAR file.

Use the help option (-h or --help) to get help on the command.
4

2 回答 2

0

没有弄清楚第一个问题,但解决了第二个问题。

内部的命令--python3导致错误。

Pyflink 的官方命令是

./bin/flink run -py word_count.py

由于我的 docker 中只有 Python3,我使用以下方法将 Python3 软链接到 Python:

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

然后官方的 Pyflink 命令就起作用了。您可以通过 Flink Web UI 看到已完成的作业。

于 2021-01-05T02:29:10.180 回答
0

默认是使用机器上的python解释器编译pyflink作业,可以通过python.client.executable更改。

于 2021-01-06T01:59:40.310 回答