【问题标题】:Pyflink : 'JavaPackage' object is not callablePyflink:“JavaPackage”对象不可调用
【发布时间】:2021-01-06 10:13:10
【问题描述】:

当我使用以下代码在 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.

【问题讨论】:

    标签: apache-flink pyflink


    【解决方案1】:

    第一个问题没解决,第二个问题解决了。

    --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 看到已完成的作业。

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-01-04
        • 2019-02-02
        • 2021-04-02
        • 2016-09-06
        • 2020-02-24
        • 2022-08-11
        • 1970-01-01
        相关资源
        最近更新 更多