title: Permission denied for mkdir
body: <p>I installed <strong>my own package</strong>  via <code>sudo python setup.py install</code> locally. In its source code there's the code which causes <code>OSError: (13, 'Permission denied', '....')</code>:</p>
  
  <pre><code>curr_dir = os.path.dirname(os.path.realpath(__file__))
      if not os.path.exists(os.path.dirname(os.path.join(curr_dir, "dir1/log1.out"))):
          os.makedirs(os.path.dirname(os.path.join(curr_dir, "dir1/log1.out")))
  </code></pre>
  
  <p>curr_dir is:</p>
  
  <pre><code>/usr/local/lib/python2.7/site-packages/my_app-1.2.3-py2.7.egg/my_app
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>$ ls -al '/usr/local/lib/python2.7/site-packages/my_app-1.2.3-py2.7.egg/my_app'
  total 696
  drwxr-xr-x  35 root  admin   1190 Mar 29 12:00 .
  drwxr-xr-x   4 root  admin    136 Mar 29 12:00 ..
  -rw-r--r--   1 root  admin    108 Mar 29 12:00 __init__.py
  -rw-r--r--   1 root  admin    202 Mar 29 12:00 __init__.pyc
  -rw-r--r--   1 root  admin  11964 Mar 29 12:00 file1.py
  -rw-r--r--   1 root  admin  12953 Mar 29 12:00 file1.pyc
  -rw-r--r--   1 root  admin  13424 Mar 29 12:00 file2.py
  -rw-r--r--   1 root  admin  15621 Mar 29 12:00 file2.pyc
  .....
  </code></pre>
  
  <p>How can I fix it?</p>
  
  <p>P.S. Even I create a file <code>curr_dir, "dir1/log1.out</code> manually by mkdir and touch, the python code also throws the same exception while being executed.</p>