1

5 月 1 日添加:
在 apache-flink 的 jira 上看到了一个关于这个错误的问题,也许它有帮助?


我的系统是CentOS7,python版本3.6.8,pyflink版本1.10.0;
我正在关注本教程并尝试运行 pyflink 文件;但我不断收到以下错误;
我曾尝试使用选项 -pyarch-pyexec venv.zip/venv/bin/python3运行它,但它没用。
我还将t_env.get_config().set_python_executable("python3")添加到 py 文件中,但仍然出现相同的错误:

[root@localhost pyflink]# flink run -m  localhost:8081  -pyarch venv.zip -pyexec venv.zip/venv/bin/python3  -py test_split_label.py 
Traceback (most recent call last):
  File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/root/wyl/test_file/pyflink/test_split_label.py", line 58, in <module>
    from pyflink.datastream import StreamExecutionEnvironment
  File "/tmp/pyflink/89713583-7229-4c30-93c9-4d543c360437/bd1f0746-4704-44e2-ba9e-3ef2bea03354pyflink.zip/pyflink/__init__.py", line 23, in <module>
RuntimeError: Python versions prior to 3.5 are not supported for PyFlink [sys.version_info(major=2, minor=7, micro=5, releaselevel='final', serial=0)].
org.apache.flink.client.program.OptimizerPlanEnvironment$ProgramAbortException
    at org.apache.flink.client.python.PythonDriver.main(PythonDriver.java:87)
    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:138)
    at org.apache.flink.client.cli.CliFrontend.executeProgram(CliFrontend.java:664)
    at org.apache.flink.client.cli.CliFrontend.run(CliFrontend.java:213)
    at org.apache.flink.client.cli.CliFrontend.parseParameters(CliFrontend.java:895)
    at org.apache.flink.client.cli.CliFrontend.lambda$main$10(CliFrontend.java:968)
    at org.apache.flink.runtime.security.NoOpSecurityContext.runSecured(NoOpSecurityContext.java:30)
    at org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:968)

我的默认 python 版本已设置为 Python3.6:

[root@localhost pyflink]# python
Python 3.6.8 (default, Aug  7 2019, 17:28:10) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.version_info
sys.version_info(major=3, minor=6, micro=8, releaselevel='final', serial=0)

看来我应该设置一些环境变量?但我不知道应该设置什么名称和路径。现在我有一个 $FLINK_HOME。
任何帮助是极大的赞赏。

4

1 回答 1

0

这是因为您使用的客户端的python环境是2.7。apiset_python_executable所做的是在集群端设置 python 可执行文件。所以如果你的 PyFlink 版本是 1.10,你需要使用 virtualenv 和 3.5+ python 环境,你可以参考文档https://ci.apache.org/projects/flink/flink-docs-release-1.10/dev/table /python/common_questions.html#execute-pyflink-jobs-with-python-virtual-environment。在 PyFlink 1.11 中,您可以直接配置PYFLINK_CLIENT_EXECUTABLE以在客户端指定 python 可执行文件。

于 2020-05-26T07:03:15.473 回答