我通过本地安装了自己的软件包。sudo python setup.py install
在其源代码中有导致OSError: (13, 'Permission denied', '....')
:
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")))
curr_dir 是:
/usr/local/lib/python2.7/site-packages/my_app-1.2.3-py2.7.egg/my_app
和:
$ 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
.....
我该如何解决?
curr_dir, "dir1/log1.out
PS 即使我通过 mkdir 和 touch 手动创建文件,python 代码在执行时也会抛出相同的异常。