视频文件打开时的权限错误

时间:2017-07-01 21:01:56

标签: python video

我正在尝试编写一个Python脚本来播放视频,但我收到此权限错误:

Traceback (most recent call last):
  File "alarm.py", line 17, in <module>
    print play_video()
  File "alarm.py", line 14, in play_video
    p = subprocess.Popen([vlc_path, video])
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception
OSError: [Errno 13] Permission denied

我已将视频和视频播放器的权限更改为755(确认它们已设置为-rwxrwxr-x),但除此之外我无法想到该怎么做。

alarm.py

import os
import subprocess


def play_video():
    video = "/path_to_video"
    vlc_path = "/path_to_vlc"
    p = subprocess.Popen([vlc_path, video])

if __name__ == '__main__':
    print play_video()

1 个答案:

答案 0 :(得分:0)

我不知道为什么我收到了无用的错误消息,但我的命令错了。应该是:

p = subprocess.Popen(['open', '-a', vlc_path, video])