简体   繁体   中英

Python multiprocessing Pool, OSError: Errno 2 No such file or directory

I'm trying to use this github repo to do some birdsong analysis. I've come across a problem in the stage where I collect all the sample's into one array( 'Collect Samples' ). I'm getting an error that looks to be something to do with my system. Not sure where to start on fixing the error. (have a look at my link to the github repo to get more in depth.) Thanks for having a look!

def job(fn):
    return load_sample(fn, sr=sr,
                       max_length=max_length, fixed_length=fixed_length)
pool = Pool()
%time results = pool.map(job, files[:limit])
print 'Processed', len(results), 'samples'


    ---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-8-5d12f8de2a12> in <module>()
      3                        max_length=max_length, fixed_length=fixed_length)
      4 pool = Pool()
----> 5 get_ipython().magic(u'time results = pool.map(job, files[:limit])')
      6 print 'Processed', len(results), 'samples'

/home/notebook/anaconda2/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s)
   2156         magic_name, _, magic_arg_s = arg_s.partition(' ')
   2157         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2158         return self.run_line_magic(magic_name, magic_arg_s)
   2159 
   2160     #-------------------------------------------------------------------------

/home/notebook/anaconda2/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_line_magic(self, magic_name, line)
   2077                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2078             with self.builtin_trap:
-> 2079                 result = fn(*args,**kwargs)
   2080             return result
   2081 

<decorator-gen-59> in time(self, line, cell, local_ns)

/home/notebook/anaconda2/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k)
    186     # but it's overkill for just that one bit of state.
    187     def magic_deco(arg):
--> 188         call = lambda f, *a, **k: f(*a, **k)
    189 
    190         if callable(arg):

/home/notebook/anaconda2/lib/python2.7/site-packages/IPython/core/magics/execution.pyc in time(self, line, cell, local_ns)
   1183         else:
   1184             st = clock2()
-> 1185             exec(code, glob, local_ns)
   1186             end = clock2()
   1187             out = None

<timed exec> in <module>()

/home/notebook/anaconda2/lib/python2.7/multiprocessing/pool.pyc in map(self, func, iterable, chunksize)
    249         '''
    250         assert self._state == RUN
--> 251         return self.map_async(func, iterable, chunksize).get()
    252 
    253     def imap(self, func, iterable, chunksize=1):

/home/notebook/anaconda2/lib/python2.7/multiprocessing/pool.pyc in get(self, timeout)
    565             return self._value
    566         else:
--> 567             raise self._value
    568 
    569     def _set(self, i, obj):

OSError: [Errno 2] No such file or directory

Also in case it helps, I'm running Python 2.7.13 |Anaconda 4.4.0.

Oh and the line that causes the error is results = pool.map(job, files[:limit])

Thanks a lot in advance.

After following my comment i posted I tried installing ffmpeg using

sudo apt-get install libav-tools

from this link . Not sure how that installs ffmpeg but it fixed the problem!

If I should delete this post please tell me, but I think it is useful for other people with a similar problem. ie. no need to learn about mappers and pools if you have a similar problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM