当我尝试通过 django 管理界面上传媒体文件时,出现以下错误:
OSError: [Errno 45] Operation not supported
这是回溯的最后一行:
File "/path/to/home/Envs/myenv/lib/python3.5/site-packages/django/core/files/locks.py", line 112, in unlock
ret = fcntl.lockf(_fd(f), fcntl.LOCK_UN)
I found 这个答案 https://stackoverflow.com/a/24764339/3156085其中一条评论让我想到这张票 https://code.djangoproject.com/ticket/9433然后到这次提交 https://github.com/django/django/commit/195420259a,在票证中作为“解决方法”引入(见下文)。
这是我应该做的改变django/core/files/locks.py
根据解决方法。
elif system_type == 'posix':
def lock(file, flags):
- fcntl.flock(fd(file), flags)
+ fcntl.lockf(fd(file), flags)
def unlock(file):
- fcntl.flock(fd(file), fcntl.LOCK_UN)
+ fcntl.lockf(fd(file), fcntl.LOCK_UN)
我尝试手动撤消此提交的更改(替换flock()
打电话给lockf()
调用),但我仍然遇到同样的错误。
还有补丁,但这些补丁似乎很旧(〜7年了,我使用 django 1.9 和 python 3.5)。
我该如何解决这个问题?
EDIT :
正如 plombix 提到的,我的主目录安装在 NFS 上。
EDIT2 :
我还尝试用fcntl.fcntl()
打电话,我得到了一个不同的错误:
OSError: [Errno 14] Bad address