uncleguanghui / pyflink_learn

基于 PyFlink 的学习文档,通过一个个小实践,便于大家快速入手 PyFlink
269 stars 97 forks source link

启动报错 TypeError: 'JavaPackage' object is not callable #10

Closed mint-octopi closed 3 years ago

mint-octopi commented 3 years ago

您好, 请问在运行代码的时候 启动环境会报错

env_settings = EnvironmentSettings.new_instance().in_batch_mode().use_blink_planner().build()

具体在 运行 EnvironmentSettings.new_instance() 就已经报错了

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/octopi/PycharmProjects/pyflink/venv/lib/python3.8/site-packages/pyflink/table/environment_settings.py", line 187, in new_instance
    return EnvironmentSettings.Builder()
  File "/Users/octopi/PycharmProjects/pyflink/venv/lib/python3.8/site-packages/pyflink/table/environment_settings.py", line 46, in __init__
    gateway = get_gateway()
  File "/Users/octopi/PycharmProjects/pyflink/venv/lib/python3.8/site-packages/pyflink/java_gateway.py", line 67, in get_gateway
    _gateway.jvm.org.apache.flink.client.python.PythonEnvUtils.resetCallbackClient(
TypeError: 'JavaPackage' object is not callable

错误位置在 java_gateway.py 这个文件中

感觉是环境问题 但是没找到相关资料 耽误大神几分钟时间解答一下, 感激

mint-octopi commented 3 years ago

这是我使用 python xxx.py 命令时出现的错误

如果使用 flink run -py xxx.py 会出现另外一种错误

    exec(code, run_globals)
  File "/var/folders/34/q1ktbtsx5hz4bxm3k7kkmjc80000gn/T/pyflink/9f4c26fe-1ec1-402f-8b00-1ac40b12f058/05ace10a-5476-40b6-a262-b0b4151a6cb1/batch.py", line 51, in <module>
    t_env.execute_sql(f"""
AttributeError: 'BatchTableEnvironment' object has no attribute 'execute_sql'
org.apache.flink.client.program.OptimizerPlanEnvironment$ProgramAbortException
        at org.apache.flink.client.python.PythonDriver.main(PythonDriver.java:96)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:321)
        at org.apache.flink.client.program.PackagedProgram.invokeInteractiveModeForExecution(PackagedProgram.java:205)
        at org.apache.flink.client.ClientUtils.executeProgram(ClientUtils.java:139)
        at org.apache.flink.client.cli.CliFrontend.executeProgram(CliFrontend.java:670)
        at org.apache.flink.client.cli.CliFrontend.run(CliFrontend.java:213)
        at org.apache.flink.client.cli.CliFrontend.parseParameters(CliFrontend.java:901)
        at org.apache.flink.client.cli.CliFrontend.lambda$main$10(CliFrontend.java:974)
        at org.apache.flink.runtime.security.NoOpSecurityContext.runSecured(NoOpSecurityContext.java:30)
        at org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:974)

会莫名其妙的显示
'BatchTableEnvironment' object has no attribute 'execute_sql'

但是点进BatchTableEnvironment是有这个方法的呀 不知道这两个情况是不是相关的, 看起来可能都是环境方面的问题

mint-octopi commented 3 years ago

问题已解决

pierce1983 commented 3 years ago

same error,SOS !!