title: FileNotFoundError while writing to a Pickle file
body: <p>I'm taking all the filenames in a certain directory in a <code>list</code>, and would like to write this list in a <code>pickle</code> file. Here's the code I am using:</p>
  <pre><code>import _pickle as pickle
  with open(filepath+'filenames.pkl', 'wb') as f:
      pickle.dump(filenames, f)
  </code></pre>
  <p>This gives me the following error:</p>
  <pre><code>---------------------------------------------------------------------------
  FileNotFoundError                         Traceback (most recent call last)
  &lt;ipython-input-32-c59e6889d2fe&gt; in &lt;module&gt;()
        1 import _pickle as pickle
  ----&gt; 2 with open(dpath+'filenames.pkl', 'wb') as f:
        3     pickle.dump(filenames, f)
  
  FileNotFoundError: [Errno 2] No such file or directory: '/data/train/filenames.pkl'
  </code></pre>
  <p>I am supposed to create this file. Why is this file expected already?</p>
  <p>(I'm using Python 3.6.)</p>