Mailing List Archive

[Errno 2] No such file or directory:
The following code fails as shown in the title:






*import subprocesscmd = 'ls -l
/media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48
| awk "{print $9 }"'process = subprocess.Popen([cmd],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)stdout, stderr =
process.communicate()print('stdout ',stdout)print('stderr ',stderr)*

----

Traceback (most recent call last):
File "PreProcess_1a.py", line 3, in <module>
process = subprocess.Popen([cmd], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
File "/home/joepareti54/anaconda3/lib/python3.8/subprocess.py", line 854,
in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/home/joepareti54/anaconda3/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: 'ls -l
/media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48
| awk "{print $9

--
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
--
https://mail.python.org/mailman/listinfo/python-list
Re: [Errno 2] No such file or directory: [ In reply to ]
On Thu, Jul 29, 2021 at 2:10 AM joseph pareti <joepareti54@gmail.com> wrote:
>
> The following code fails as shown in the title:
>
>
>
>
>
>
> *import subprocesscmd = 'ls -l
> /media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48
> | awk "{print $9 }"'process = subprocess.Popen([cmd],
> stdout=subprocess.PIPE, stderr=subprocess.PIPE)stdout, stderr =
> process.communicate()print('stdout ',stdout)print('stderr ',stderr)*
>
> ----
>
> Traceback (most recent call last):
> File "PreProcess_1a.py", line 3, in <module>
> process = subprocess.Popen([cmd], stdout=subprocess.PIPE,
> stderr=subprocess.PIPE)
> File "/home/joepareti54/anaconda3/lib/python3.8/subprocess.py", line 854,
> in __init__
> self._execute_child(args, executable, preexec_fn, close_fds,
> File "/home/joepareti54/anaconda3/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: 'ls -l
> /media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48
> | awk "{print $9
>

First off, you'll want to post code in a way that keeps the
formatting, otherwise it becomes very hard to read.

But the immediate problem here is that Popen takes an array of command
arguments, NOT a shell command line. You cannot invoke ls and pipe it
into awk this way.

Don't think like a shell script. Python has very good
directory-listing functionality, and you will very very seldom need to
shell out to pipelines. Figure out what you actually need to learn
from the directory listing and get that information directly, rather
than trying to use two external commands and text parsing. It's far
FAR easier, cleaner, and safer that way.

ChrisA
--
https://mail.python.org/mailman/listinfo/python-list
Re: [Errno 2] No such file or directory: [ In reply to ]
On 28/07/2021 18:09, joseph pareti wrote:
> The following code fails as shown in the title:
>
>
>
>
>
>
> *import subprocesscmd = 'ls -l
> /media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48
> | awk "{print $9 }"'process = subprocess.Popen([cmd],

As a quick fix try

process = subprocess.Popen(
cmd # no list
shell=True,
... # other args as above
)

> stdout=subprocess.PIPE, stderr=subprocess.PIPE)stdout, stderr =
> process.communicate()print('stdout ',stdout)print('stderr ',stderr)*
>
> ----
>
> Traceback (most recent call last):
> File "PreProcess_1a.py", line 3, in <module>
> process = subprocess.Popen([cmd], stdout=subprocess.PIPE,
> stderr=subprocess.PIPE)
> File "/home/joepareti54/anaconda3/lib/python3.8/subprocess.py", line 854,
> in __init__
> self._execute_child(args, executable, preexec_fn, close_fds,
> File "/home/joepareti54/anaconda3/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: 'ls -l
> /media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48
> | awk "{print $9
>


--
https://mail.python.org/mailman/listinfo/python-list
Re: [Errno 2] No such file or directory: [ In reply to ]
indeed. There are better options than the one I attempted. Thanks for the
advice

Am Mi., 28. Juli 2021 um 18:19 Uhr schrieb Chris Angelico <rosuav@gmail.com
>:

> On Thu, Jul 29, 2021 at 2:10 AM joseph pareti <joepareti54@gmail.com>
> wrote:
> >
> > The following code fails as shown in the title:
> >
> >
> >
> >
> >
> >
> > *import subprocesscmd = 'ls -l
> >
> /media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48
> > | awk "{print $9 }"'process = subprocess.Popen([cmd],
> > stdout=subprocess.PIPE, stderr=subprocess.PIPE)stdout, stderr =
> > process.communicate()print('stdout ',stdout)print('stderr ',stderr)*
> >
> > ----
> >
> > Traceback (most recent call last):
> > File "PreProcess_1a.py", line 3, in <module>
> > process = subprocess.Popen([cmd], stdout=subprocess.PIPE,
> > stderr=subprocess.PIPE)
> > File "/home/joepareti54/anaconda3/lib/python3.8/subprocess.py", line
> 854,
> > in __init__
> > self._execute_child(args, executable, preexec_fn, close_fds,
> > File "/home/joepareti54/anaconda3/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: 'ls -l
> >
> /media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48
> > | awk "{print $9
> >
>
> First off, you'll want to post code in a way that keeps the
> formatting, otherwise it becomes very hard to read.
>
> But the immediate problem here is that Popen takes an array of command
> arguments, NOT a shell command line. You cannot invoke ls and pipe it
> into awk this way.
>
> Don't think like a shell script. Python has very good
> directory-listing functionality, and you will very very seldom need to
> shell out to pipelines. Figure out what you actually need to learn
> from the directory listing and get that information directly, rather
> than trying to use two external commands and text parsing. It's far
> FAR easier, cleaner, and safer that way.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>


--
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
--
https://mail.python.org/mailman/listinfo/python-list
Re: [Errno 2] No such file or directory: [ In reply to ]
On Thursday, July 29, 2021 at 7:42:58 AM UTC-7, joseph pareti wrote:
> indeed. There are better options than the one I attempted. Thanks for the
> advice
>
> Am Mi., 28. Juli 2021 um 18:19 Uhr schrieb Chris Angelico <ros...@gmail.com
> >:
> > On Thu, Jul 29, 2021 at 2:10 AM joseph pareti <joepa...@gmail.com>
> > wrote:
> > >
> > > The following code fails as shown in the title:
> > >
> > >
> > >
> > >
> > >
> > >
> > > *import subprocesscmd = 'ls -l
> > >
> > /media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48
> > > | awk "{print $9 }"'process = subprocess.Popen([cmd],
> > > stdout=subprocess.PIPE, stderr=subprocess.PIPE)stdout, stderr =
> > > process.communicate()print('stdout ',stdout)print('stderr ',stderr)*
> > >
> > > ----
> > >
> > > Traceback (most recent call last):
> > > File "PreProcess_1a.py", line 3, in <module>
> > > process = subprocess.Popen([cmd], stdout=subprocess.PIPE,
> > > stderr=subprocess.PIPE)
> > > File "/home/joepareti54/anaconda3/lib/python3.8/subprocess.py", line
> > 854,
> > > in __init__
> > > self._execute_child(args, executable, preexec_fn, close_fds,
> > > File "/home/joepareti54/anaconda3/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: 'ls -l
> > >
> > /media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48
> > > | awk "{print $9
> > >
> >
> > First off, you'll want to post code in a way that keeps the
> > formatting, otherwise it becomes very hard to read.
> >
> > But the immediate problem here is that Popen takes an array of command
> > arguments, NOT a shell command line. You cannot invoke ls and pipe it
> > into awk this way.
> >
> > Don't think like a shell script. Python has very good
> > directory-listing functionality, and you will very very seldom need to
> > shell out to pipelines. Figure out what you actually need to learn
> > from the directory listing and get that information directly, rather
> > than trying to use two external commands and text parsing. It's far
> > FAR easier, cleaner, and safer that way.
> >
> > ChrisA
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
>
>
> --
> Regards,
> Joseph Pareti - Artificial Intelligence consultant
> Joseph Pareti's AI Consulting Services
> https://www.joepareti54-ai.com/
> cell +49 1520 1600 209
> cell +39 339 797 0644

I prefer LOLCODE for these kinds of tasks.

HAI 1.2
I HAS A VAR ITZ MAH_DIRECTORY
GIMMEH MAH_DIRECTORY

CAN HAS STDIO?
BOTH SAEM MAH_DIRECTORY AN "/media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48", O RLY?
YA RLY, VISIBLE "FILEZ GO HERE!"
NO WAI, VISIBLE "WTF IZ THAT?"
OIC

KTHXBYE
--
https://mail.python.org/mailman/listinfo/python-list