OSError:[错误1]操作不允许shutil.move

时间:2014-09-08 01:33:03

标签: python linux shutil

所以我尝试使用python将文件从启动驱动器复制到外部。因此,os.rename不是一个选项(我会得到一个跨设备错误)。我决定尝试使用shutil.move但是这会抛出OSError 1,声称不允许对os.chmod的内部调用进行操作。有趣的是它正在移动的目录具有权限777.调用如下:

if hasattr(f.file,'name'):
                    move(f.file.name,path)

全栈交易如下。

[08/Sep/2014:00:49:36] HTTP Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/cherrypy/_cprequest.py", line 670
, in respond
    response.body = self.handler()
  File "/usr/local/lib/python2.7/dist-packages/cherrypy/lib/encoding.py", line 2
17, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/cherrypy/_cpdispatch.py", line 61
, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/home/pi/btsync/BitTorrentSyncWeb/py/main.py", line 129, in upload
    move(f.file.name,path)
  File "/usr/lib/python2.7/shutil.py", line 301, in move
    copy2(src, real_dst)
  File "/usr/lib/python2.7/shutil.py", line 131, in copy2
    copystat(src, dst)
  File "/usr/lib/python2.7/shutil.py", line 100, in copystat
    os.chmod(dst, mode)
OSError: [Errno 1] Operation not permitted: '/mnt/bakery/Dump/ck.gif'

权限如下所示

$ls -l /mnt/bakery/
    drwxrwxrwx 4 root root 32768 Sep  8 01:30 Dump
$ls -l /mnt/bakery/Dump |grep ck.gif
    -rwxrwxrwx 1 root root 1017711 Sep  8 00:49 ck.gif

1 个答案:

答案 0 :(得分:-1)

请确保您的驱动器具有linux可以chmod的格式。 FAT32不是其中之一。