subprocess fails to call a function - python-3.x

I am trying to call a function using subprocess.Popen as:
proc = subprocess.Popen(["/usr/local/bin/qstat", "-u", "rudrab"],stdout=subprocess.PIPE)
numjobs = proc.stdout.read()
which is giving error:
Traceback (most recent call last):
File "genpos.py", line 159, in <module>
proc = subprocess.Popen(["/usr/local/bin/qstat", "-u", "rudrab"],stdout=subprocess.PIPE)
File "/opt/python-3.5/lib/python3.5/subprocess.py", line 950, in __init__
restore_signals, start_new_session)
File "/opt/python-3.5/lib/python3.5/subprocess.py", line 1544, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/bin/qstat'
but qstat is in my path:
which qstat
/usr/local/bin/qstat
what I am doing wrong here?

Related

Cannot find specified path: Whisper Error, python 3.7.7

Traceback (most recent call last):
File "C:\Users\SAMSUNG\Desktop\Whisper\test.py", line 4, in
audio = whisper.load_audio("audio.mp3")
File "C:\Users\SAMSUNG\AppData\Local\Programs\Python\Python37\lib\site-packages\whisper\audio.py", line 44, in load_audio
.run(cmd=["ffmpeg", "-nostdin"], capture_stdout=True, capture_stderr=True)
File "C:\Users\SAMSUNG\AppData\Local\Programs\Python\Python37\lib\site-packages\ffmpeg_run.py", line 320, in run
overwrite_output=overwrite_output,
File "C:\Users\SAMSUNG\AppData\Local\Programs\Python\Python37\lib\site-packages\ffmpeg_run.py", line 285, in run_async
args, stdin=stdin_stream, stdout=stdout_stream, stderr=stderr_stream
File "C:\Users\SAMSUNG\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 800, in init
restore_signals, start_new_session)
File "C:\Users\SAMSUNG\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 1207, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

problem running "command -v dnf" in python

I'm trying to run this code:
import subprocess
def install_curl():
result = subprocess.check_output(['command', '-v', 'dnf']) #
if not result:
print("You should Install curl")
else:
result = subprocess.check_output(['command', '-v', 'apt'])
print(result)
install_curl()
Then I'm getting this error:
Traceback (most recent call last):
File "/home/pbravodez1/projects/Automate_task/test_gpg.py", line 98, in <module>
install_curl()
File "/home/pbravodez1/projects/Automate_task/test_gpg.py", line 91, in install_curl
result = subprocess.check_output(['command', '-v', 'dnf']) #
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: 'command'
Do you have any idea on how to run this "command" in order to check which package manager is installed in the Operating System?

Sometimes throws Bad file descriptor error, sometimes doesn't

The following piece of code was working fine for a year, of late it intermittently started failing with following error, wonder if any OS or hardware change is causing this
import subprocess
def bash_command(cmd):
process = subprocess.Popen(cmd, shell=True, executable="/bin/bash")
process.wait()
bash_command("bash myscript.sh")
The error message is:
Traceback (most recent call last): File
"/Users/ishandutta2007/Documents/Projects/p2/shell_way/all_in_one_refill.py",
line 68,
bash myscript.sh File "/Users/ishandutta2007/Documents/Projects/p2/shell_way/all_in_one_refill.py",
line 31, in bash_command
process = subprocess.Popen(cmd, shell=True, executable="/bin/bash") File
"/Users/ishandutta2007/.pyenv/versions/3.6.0/lib/python3.6/subprocess.py",
line 707, in __init__
restore_signals, start_new_session) File "/Users/ishandutta2007/.pyenv/versions/3.6.0/lib/python3.6/subprocess.py",
line 1326, in _execute_child
raise child_exception_type(errno_num, err_msg) OSError: [Errno 9] Bad file descriptor

OSError: [Errno 8] Exec format error while reading video Moviepy

I'm trying to run a video processing code on NVIDIA TX2 using moviepy. The code is:
clip = VideoFileClip(video_file)
video_clip = clip.fl_image(process_vid)
video_clip.write_videofile(output_vid2)
I get the error in the first line. The full error is:
Traceback (most recent call last):
File "img_test.py", line 117, in <module>
clip = VideoFileClip(video_file)
File "/home/nvidia/.local/lib/python3.5/site-packages/moviepy/video/io/VideoFileClip.py", line 91, in __init__
fps_source=fps_source)
File "/home/nvidia/.local/lib/python3.5/site-packages/moviepy/video/io/ffmpeg_reader.py", line 33, in __init__
fps_source)
File "/home/nvidia/.local/lib/python3.5/site-packages/moviepy/video/io/ffmpeg_reader.py", line 256, in ffmpeg_parse_infos
proc = sp.Popen(cmd, **popen_params)
File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg)
OSError: [Errno 8] Exec format error
I even used the refernce of this but nothing seems to work.
Any suggestions?

When trying to install GDAL with pip to a macOS I keep getting an error about a file not found, shouldn't the installer have all of the files?

When I try using pip install to get GDAL I run into an error about a file not found. I went to the location and there is definitely no folder there but shouldn't the installer install the folder it needs first?
Collecting GDAL
Using cached https://files.pythonhosted.org/packages/7c/b0/a2ecb10a68a319910c4681f452c83843b99c4ef6231d33a8e55b0104a50c/GDAL-2.4.0.tar.gz
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/GDAL.egg-info
writing pip-egg-info/GDAL.egg-info/PKG-INFO
writing dependency_links to pip-egg-info/GDAL.egg-info/dependency_links.txt
writing top-level names to pip-egg-info/GDAL.egg-info/top_level.txt
writing manifest file 'pip-egg-info/GDAL.egg-info/SOURCES.txt'
Traceback (most recent call last):
File "/private/var/folders/js/c2_gdy711m7933z9bxcv2q5h0000gn/T/pip-install-jv2fugnm/GDAL/setup.py", line 151, in fetch_config
p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '../../apps/gdal-config': '../../apps/gdal-config'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/private/var/folders/js/c2_gdy711m7933z9bxcv2q5h0000gn/T/pip-install-jv2fugnm/GDAL/setup.py", line 237, in get_gdal_config
return fetch_config(option, gdal_config=self.gdal_config)
File "/private/var/folders/js/c2_gdy711m7933z9bxcv2q5h0000gn/T/pip-install-jv2fugnm/GDAL/setup.py", line 154, in fetch_config
raise gdal_config_error(e)
__main__.gdal_config_error: [Errno 2] No such file or directory: '../../apps/gdal-config': '../../apps/gdal-config'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/private/var/folders/js/c2_gdy711m7933z9bxcv2q5h0000gn/T/pip-install-jv2fugnm/GDAL/setup.py", line 151, in fetch_config
p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'gdal-config': 'gdal-config'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/js/c2_gdy711m7933z9bxcv2q5h0000gn/T/pip-install-jv2fugnm/GDAL/setup.py", line 430, in <module>
setup(**setup_kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/__init__.py", line 143, in setup
return distutils.core.setup(**attrs)
.................................
File "/private/var/folders/js/c2_gdy711m7933z9bxcv2q5h0000gn/T/pip-install-jv2fugnm/GDAL/setup.py", line 154, in fetch_config
raise gdal_config_error(e)
__main__.gdal_config_error: [Errno 2] No such file or directory: 'gdal-config': 'gdal-config'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/js/c2_gdy711m7933z9bxcv2q5h0000gn/T/pip-install-jv2fugnm/GDAL/

Resources