Имя файла Main.py
import subprocess
Interface = "eth0"
output1 = subprocess.check_output(["ifconfig", Interface])
, когда я пытаюсь выполнить выше, я получаю следующую ошибку.
/kunal/PycharmProjects/first/venv/bin/python /kunal/PycharmProjects/first/main.py
Traceback (most recent call last):
File "/kunal/PycharmProjects/first/main.py", line 4, in <module>
output1 = subprocess.check_output(["ifconfig", Interface])
File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/lib/python3.8/subprocess.py", line 489, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ifconfig'
Process finished with exit code 1
Соответствующая часть среды при запуске Программа выглядит так:
HOME: /kunal
PATH: /kunal/PycharmProjects/first/venv/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
PS1: (venv)
PWD: /kunal/PycharmProjects/first
PYCHARM_HOSTED: 1
PYTHONIOENCODING: UTF-8
PYTHONPATH: /kunal/PycharmProjects/first
PYTHONUNBUFFERED: 1
SHELL: /bin/bash
USER: kunal
VIRTUAL_ENV: /kunal/PycharmProjects/first/venv
Путь 'env' в оболочке:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Результат для "which ifconfig":
/usr/sbin/ifconfig