【问题标题】:I am getting permission error to a folder when I try opening it with io.open当我尝试使用 io.open 打开某个文件夹时出现权限错误
【发布时间】:2022-01-13 02:03:08
【问题描述】:

我正在尝试运行这段code,但出现权限错误。你建议什么解决方案?我可以用别的东西替换io.open吗:

"""Detect labels given a file path."""
video_client = videointelligence.VideoIntelligenceServiceClient()
features = [videointelligence.Feature.LABEL_DETECTION]

cwd = "E:/.../Google_Video_API/videos/"
with io.open(cwd, "rb") as movie:
    input_content = movie.read()

operation = video_client.annotate_video(
    request={"features": features, "input_content": input_content}
)
print("\nProcessing video for label annotations:")

这是我得到的错误:PermissionError: [Errno 13] Permission denied: 'E:/.../Google_Video_API/videos/'

【问题讨论】:

    标签: python-3.x google-cloud-platform google-api-client


    【解决方案1】:

    有几个问题:

    1. io.open 需要文件而不是目录; cwd 看起来是一个目录
    2. cwd = "E:/.../Google_Video_API/videos/" 包括 ...,对吗?

    【讨论】:

    • 这个答案是正确的。请注意,Linux 系统上的目录是一种特殊类型的文件,只要应用程序具有访问目录的正确权限,就可以打开它们。
    猜你喜欢
    • 1970-01-01
    • 2019-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-25
    • 2016-11-13
    • 1970-01-01
    • 2020-11-17
    相关资源
    最近更新 更多