title: Permission Denied While Accessing Files in Anaconda Prompt
body: <p>I have a Python script that accesses some files, form example one line of code appends some text to a .txt file. 
  It runs correctly in a normal cmd.exe, with or without Admnistrator access. But while using a Anaconda Prompt or a cmd.exe opened from Anaconda Navigator it gives a <code>PermissionError: [Errno 13] Permission denied:</code> in the <code>open('path/to/file', 'a+')</code> line.</p>
  
  <p>I'm looking for a solution for why Anaconda's python cannot access files. Another line of code using the function <code>handlers.TimedRotatingFileHandler()</code> from the logging module also throws the same error.</p>
  
  <p>Some info that might be useful:</p>
  
  <ul>
  <li>I have two Anaconda environments, one with python 2.7 and another one with python 3.6.6, both throw the error;</li>
  <li>I have installed Anaconda 3 without adding anaconda to my PATH, because it was recommended in the installer;</li>
  <li>My PATH's python, the version that works in the non-anaconda cmd.exe, is also 3.6.6;</li>
  <li>I use Windows 10.</li>
  </ul>
  
  <h1>Edit:</h1>
  
  <p>Okay, so there seems to be some confusion about what I'm trying to accomplish. I'm making a text file with every .jpg file in a folder recursively, followed by the split of the file name. The text file should have: "path/to/XY_file_XY.jpg file" for every file found. Those splits represent the labels of the images for a neural network I'm training. </p>
  
  <p>Here is my code for creating this text file:</p>
  
  <pre><code>import glob
  
  class DBSetter(object):
      def __init__(self, rootPath = 'C:\\Users\\Victor.Lundgren\\Google Drive\\Mestrado\\VC\\Projeto\\data\\mnt'):
          self.path = rootPath
          return
  
      def setDB(self, extension = '.jpg', splitFileName = True, splitDilimiter = '_', splitPosition = 1):
          query = self.path+'\\**\\*'+extension
          print(query)
          fileList = glob.glob(query, recursive = True)
          sampleFileText = ''
          for file in fileList:
              word = file.split('\\')[-1]
              if splitFileName:
                  word = word.split(splitDilimiter)[splitPosition]
              sampleFileText += file+' '+word+'\n'
          print('Sample File Text created.')
          sampleFile = open(self.path+'\\sample.txt', 'a+')
          sampleFile.write(sampleFileText)
          sampleFile.close()
          return
  </code></pre>
  
  <p>For instance, let's create a DBSetter object in a <strong>main</strong>.py and test ir with the default Python (3.6.6) in a simple cmd.exe and with Anaconda's Python (3.6.6) in an Anaconda Prompt:</p>
  
  <pre><code>from utils import database_setter
  
  setter = database_setter.DBSetter('C:\\Users\\Victor.Lundgren\\Pictures\\Trabalho\\ASA') #choosing this folder for this example because it has few files in it.
  setter.setDB(extension = '.png', splitFileName = False)
  </code></pre>
  
  <p>Here we have our cmd history in a simple cmd.exe calling <strong>main</strong>.py:</p>
  
  <pre><code>&gt; Microsoft Windows [versão 10.0.16299.492] (c) 2017 Microsoft
  &gt; Corporation. Todos os direitos reservados. Clink v0.4.9 [git:2fd2c2]
  &gt; Copyright (c) 2012-2016 Martin Ridgers http://mridgers.github.io/clink
  &gt; 
  &gt; 
  &gt; C:\Users\Victor.Lundgren&gt;cd C:\Users\Victor.Lundgren\Google Drive\Mestrado\VC\Projeto
  &gt; 
  &gt; C:\Users\Victor.Lundgren\Google Drive\Mestrado\VC\Projeto&gt;Python
  &gt; __main__.py C:\Users\Victor.Lundgren\Pictures\Trabalho\ASA\**\*.png Sample File Text created.
  &gt; 
  &gt; C:\Users\Victor.Lundgren\Google Drive\Mestrado\VC\Projeto&gt;
  </code></pre>
  
  <p>Now executing Anaconda Promp from the windows menu and runnning the same thing with my Python 3.6.6 env:</p>
  
  <pre><code>&gt; Clink v0.4.9 [git:2fd2c2] Copyright (c) 2012-2016 Martin Ridgers
  &gt; http://mridgers.github.io/clink
  &gt; 
  &gt; 
  &gt; (base) C:\Users\Victor.Lundgren&gt;cd C:\Users\Victor.Lundgren\Google Drive\Mestrado\VC\Projeto
  &gt; 
  &gt; (base) C:\Users\Victor.Lundgren\Google Drive\Mestrado\VC\Projeto&gt;activate Py3
  &gt; 
  &gt; (Py3) C:\Users\Victor.Lundgren\Google Drive\Mestrado\VC\Projeto&gt;Python
  &gt; __main__.py C:\Users\Victor.Lundgren\Pictures\Trabalho\ASA\**\*.png Sample File Text created. Traceback (most recent call last):   File
  &gt; "__main__.py", line 6, in &lt;module&gt;
  &gt;     setter.setDB(extension = '.png', splitFileName = False)   File "C:\Users\Victor.Lundgren\Google Drive\Mestrado\VC\Projeto\utils\database_setter.py", line 19, in setDB
  &gt;     sampleFile = open(self.path+'\\sample.txt', 'a+') PermissionError: [Errno 13] Permission denied:
  &gt; 'C:\\Users\\Victor.Lundgren\\Pictures\\Trabalho\\ASA\\sample.txt'
  &gt; 
  &gt; (Py3) C:\Users\Victor.Lundgren\Google Drive\Mestrado\VC\Projeto&gt;
  </code></pre>