我有一个python-3.6.5代码,它使用Sub InsertMissingDates()
Dim i As Long
Dim RowCount As Long
Dim WhichCol As String
i = 4
WhichCol = "D"
Do
If Cells(i, WhichCol) + 1 < Cells(i + 1, WhichCol) Then
Rows(i + 1).Insert
Cells(i + 1, WhichCol) = Cells(i, WhichCol) + 1
End If
If (Cells(i + 1, WhichCol) = "") Then
Cells(i + 1, WhichCol) = Cells(i, WhichCol) + 1
End If
i = i + 1
Loop Until Cells(i, WhichCol).Value >= DateSerial(2016, 1, 30)
End Sub
复制文件。使用它时出现权限错误,并且无法跟踪错误源。以下是适当的代码段:
shutil.copy2()
我收到这个有趣的权限错误。我很困惑b / c该文件没有任何有趣的权限。例如
>>> genome='HCC2A1.bin.22.fa'
>>> output_folder='/gpfs0/home/group/user/Scratch/somedir/output_directory3/dereplicated_genomes/'
>>> loc='/gpfs0/home/group/user/Scratch/somedir/HCC2A1.bin.22.fa'
>>> shutil.copy2(loc, "{0}{1}".format(output_folder,genome))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/python/3.6.5/lib/python3.6/shutil.py", line 258, in copy2
copystat(src, dst, follow_symlinks=follow_symlinks)
File "/opt/python/3.6.5/lib/python3.6/shutil.py", line 225, in copystat
_copyxattr(src, dst, follow_symlinks=follow)
File "/opt/python/3.6.5/lib/python3.6/shutil.py", line 165, in _copyxattr
os.setxattr(dst, name, value, follow_symlinks=follow_symlinks)
PermissionError: [Errno 13] Permission denied: '/gpfs0/home/group/user/Scratch/somedir/output_directory3/dereplicated_genomes/HCC2A1.bin.22.fa'
此外,实际上是~$ ls -l /gpfs0/home/group/user/Scratch/somedir/HCC2A1.bin.22.fa
-rwxrwxrwx. 1 user group 4850851 Aug 29 13:21 /gpfs0/home/group/user/Scratch/somedir/HCC2A1.bin.22.fa
试图创建(并且据说失败了)的文件 ,该文件似乎具有适当的权限。例如
shutil.copy2
我试图在系统级模块内设置断点(以进行进一步研究),但无济于事。例如。 (从上面继续python解释器代码...)
~$ ls -l /gpfs0/home/group/user/Scratch/somedir/output_directory3/dereplicated_genomes/
total 4768
-rwxrwxrwx. 1 user group 4850851 Aug 29 13:21 HCC2A1.bin.22.fa
问题
>>> import pdb; pdb.set_trace()
--Return--
<function save_history at 0x2aeccefafb70>
> <stdin>(1)<module>()->None
(Pdb) b /gpfs0/export/opt/python/3.6.5/lib/python3.6/shutil.py : 255
Breakpoint 2 at /gpfs0/export/opt/python/3.6.5/lib/python3.6/shutil.py:255
(Pdb) b
Num Type Disp Enb Where
1 breakpoint keep yes at /gpfs0/export/opt/python/3.6.5/lib/python3.6/shutil.py:165
2 breakpoint keep yes at /gpfs0/export/opt/python/3.6.5/lib/python3.6/shutil.py:255
(Pdb) shutil.copy2(loc, "{0}{1}".format(output_folder,genome))
*** PermissionError: [Errno 13] Permission denied: '/gpfs0/home/group/user/Scratch/somedir/output_directory3/dereplicated_genomes/HCC2A1.bin.22.fa'
为什么失败?它肯定会创建文件,并且我已经给出了避免符号链接的绝对路径名。 shutil.copy2()
上没有任何奇怪的权限设置。
为什么不能在系统级HCC2A1.bin.22.fa
上设置断点?