python subprocess.Popen

该函数有个env参数,若果env=None, 则意味着继承父进程的环境变量,否则使用env作为环境变量,需要注意的是, 当env!=None时,则必须为映射类型,且映射值不能为int类型,也不能为None, ,否则报如下错误:

  File "test_local_hadooop_runner.py", line 85, in test_local_hadoop_runner
    task_runner.exec_task()
  File "/home/vis/personal_code/driver-python3/test/../driver_python3/runners/local_runner.py", line 78, in exec_task
    returncode = self.exec_cmd(self.entry, self.env_info)
  File "/home/vis/personal_code/driver-python3/test/../driver_python3/runners/runner.py", line 211, in exec_cmd
    p = subprocess.Popen(cmd, shell=shell, env=env_info)
  File "/home/vis/tools/python3.8/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/home/vis/tools/python3.8/lib/python3.8/subprocess.py", line 1624, in _execute_child
    env_list.append(k + b'=' + os.fsencode(v))
  File "/home/vis/tools/python3.8/lib/python3.8/os.py", line 804, in fsencode
    filename = fspath(filename)  # Does type-checking of `filename`.
TypeError: expected str, bytes or os.PathLike object, not int.

 

 

Traceback (most recent call last):
  File "/home/vis/tools/python3.8/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/home/vis/tools/python3.8/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "test_local_hadooop_runner.py", line 82, in kill_task
    self.task_runner.kill_task()
  File "/home/vis/personal_code/driver-python3/test/../driver_python3/runners/runner.py", line 147, in kill_task
    self.kill_hadoop()
  File "/home/vis/personal_code/driver-python3/test/../driver_python3/runners/runner.py", line 188, in kill_hadoop
    returncode = self.exec_cmd(kill_hadoop, self.env_info, type="kill_hadoop")
  File "/home/vis/personal_code/driver-python3/test/../driver_python3/runners/runner.py", line 218, in exec_cmd
    p = subprocess.Popen(cmd, shell=shell, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
  File "/home/vis/tools/python3.8/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/home/vis/tools/python3.8/lib/python3.8/subprocess.py", line 1624, in _execute_child
    env_list.append(k + b'=' + os.fsencode(v))
  File "/home/vis/tools/python3.8/lib/python3.8/os.py", line 804, in fsencode
    filename = fspath(filename)  # Does type-checking of `filename`.
TypeError: expected str, bytes or os.PathLike object, not NoneType

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值