Python Linux Subprocess.Call

问题描述 投票:0回答:0

我有一个在 Windows 上运行的脚本,但是当我在 Linux 上运行它时出错。

我正在运行子进程调用以调用 python 脚本并传递一个字符串变量。|

当我运行它时,它说找不到文件无法正常运行 pythonfile.py.

是的,Python 文件与激活的脚本位于同一目录中。

subprocess.run(['python','pythonfile.py',str(parsed_response)],shell = True)

错误

pythonfile.py: 1: python: not found with shell
subprocess.call(['python', 'pythonfile.py',  str(parsed_response)])

错误

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/telethon/client/updates.py", line 543, in _dispatch_update
    await callback(event)
  File "/home/user/Desktop/Tel_To_Disc_Bot/forwardgram.py", line 85, in handler
    subprocess.run(['python', 'pythonfile.py', parsed_response])
  File "/usr/lib/python3.10/subprocess.py", line 501, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.10/subprocess.py", line 969, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1845, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'python'
python-3.x linux subprocess
© www.soinside.com 2019 - 2024. All rights reserved.