问题描述
当我使用以下代码在 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.
解决方法
第一个问题没搞清楚,但解决了第二个问题。
--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 查看完成的作业。
,默认使用机器上的python解释器编译pyflink作业,可以通过python.client.executable修改。