Hi,
我单独测试了下python的虚拟环境使用,发现目标机器必须存在python的环境,不然复制了虚拟环境过去也是无法执行的,
还以为虚拟环境复制过去就可以跑起来了,和我想的不太一样,哈哈~


3.6版本报错
# ./python
./python: error while loading shared libraries: libpython3.6m.so.1.0: cannot 
open shared object file: No such file or directory


3.9版本报错

# ./venv/bin/python

Could not find platform independent libraries <prefix>

Could not find platform dependent libraries <exec_prefix>

Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]

Python path configuration:

  PYTHONHOME = (not set)

  PYTHONPATH = (not set)

  program name = './venv/bin/python'

  isolated = 0

  environment = 1

  user site = 1

  import site = 1

  sys._base_executable = '/root/tmp/venv/bin/python'

  sys.base_prefix = '/usr/local'

  sys.base_exec_prefix = '/usr/local'

  sys.platlibdir = 'lib'

  sys.executable = '/root/tmp/venv/bin/python'

  sys.prefix = '/usr/local'

  sys.exec_prefix = '/usr/local'

  sys.path = [

    '/usr/local/lib/python39.zip',

    '/usr/local/lib/python3.9',

    '/usr/local/lib/lib-dynload',

  ]

Fatal Python error: init_fs_encoding: failed to get the Python codec of the 
filesystem encoding

Python runtime state: core initialized

ModuleNotFoundError: No module named 'encodings'




Current thread 0x00007ff010275740 (most recent call first):

<no Python frame>




Thanks





在 2022-11-23 09:25:04,"RS" <tinyshr...@163.com> 写道:
>Hi,
>我这边使用的python命令构建的,没有用conda,这个应该没有影响吧
>python3 -m venv jxy_venv
>
>
>我启动了一个单点的flink测试,本机启动,有python环境,测试是可以运行成功的
>
>
>
>Thanks
>
>
>
>
>
>在 2022-11-22 15:39:48,"Xingbo Huang" <hxbks...@gmail.com> 写道:
>>Hi RS,
>>
>>你是使用conda构建的venv吗,可以参考PyFlink 准备环境的文档[1]
>>
>>Best,
>>Xingbo
>>
>>[1]
>>https://pyflink.readthedocs.io/en/latest/getting_started/installation/prepare.html#create-a-virtual-environment-using-conda
>>
>>RS <tinyshr...@163.com> 于2022年11月22日周二 15:14写道:
>>
>>> Hi,
>>> Flink版本:1.15.1
>>>
>>>
>>> A机器:在A机器上创建python虚拟环境,版本3.6.8,安装flink等python包,然后打包ZIP,jxy_venv.zip,上传到HDFS上
>>> B机器:在B机器上,主机上没有Python环境,Flink运行在K8S的docker中,docker里面也没有python环境,
>>> C机器:在C机器上,有flink的client,存在python环境,负责启动任务
>>>
>>>
>>> 启动命令:
>>> ./bin/flink run -Dexecution.runtime-mode=BATCH -d -m 192.168.1.2:8081 -n
>>> -py /xxx/main.py -pyfs hdfs://xxx/config.py -pyarch
>>> hdfs://xxx/jxy_venv.zip#venv -pyclientexec venv/jxy_venv/bin/python
>>>
>>>
>>> 报错信息:
>>> ...
>>> venv/jxy_venv/bin/python: symbol lookup error: venv/jxy_venv/bin/python:
>>> undefined symbol: _Py_LegacyLocaleDetected
>>> org.apache.flink.client.program.ProgramAbortException:
>>> java.lang.RuntimeException: Python process exits with code: 127
>>>         at
>>> org.apache.flink.client.python.PythonDriver.main(PythonDriver.java:140)
>>>         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:355)
>>>         at
>>> org.apache.flink.client.program.PackagedProgram.invokeInteractiveModeForExecution(PackagedProgram.java:222)
>>>         at
>>> org.apache.flink.client.ClientUtils.executeProgram(ClientUtils.java:114)
>>>         at
>>> org.apache.flink.client.cli.CliFrontend.executeProgram(CliFrontend.java:836)
>>>         at
>>> org.apache.flink.client.cli.CliFrontend.run(CliFrontend.java:247)
>>>         at
>>> org.apache.flink.client.cli.CliFrontend.parseAndRun(CliFrontend.java:1078)
>>>         at
>>> org.apache.flink.client.cli.CliFrontend.lambda$main$10(CliFrontend.java:1156)
>>>         at java.security.AccessController.doPrivileged(Native Method)
>>>         at javax.security.auth.Subject.doAs(Subject.java:422)
>>>         at
>>> org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1729)
>>>         at
>>> org.apache.flink.runtime.security.contexts.HadoopSecurityContext.runSecured(HadoopSecurityContext.java:41)
>>>         at
>>> org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:1156)
>>> Caused by: java.lang.RuntimeException: Python process exits with code: 127
>>>         at
>>> org.apache.flink.client.python.PythonDriver.main(PythonDriver.java:130)
>>>         ... 16 more
>>>
>>>
>>> 请问下,这种情况需要怎么处理 ?
>>> flink的环境中,一定要安装python命令吗?
>>>
>>>
>>> Thanks
>>>
>>>

回复