在我运行在googlecloudvm实例上的python服务器脚本中,它试图在存储器中保存一个图像(jpeg)。但它抛出了以下错误。在
File "/home/thamindudj_16/server/object_detection/object_detector.py", line 109, in detect Hand new_img.save("slicedhand/{}#sliced_image{}.jpeg".format(threadname, i)) File
"/home/thamindudj_16/.local/lib/python3.5/site-packages/PIL/Image.py", line 2004, in save fp = builtins.open(filename, "w+b")
OSError: [Errno 5] Input/output error: 'slicedhand/thread_1#sliced_image0.jpeg'
包括python脚本在内的所有文件都位于google存储桶中,并使用gcsfuse装载到VM实例中。应用程序尝试将新图像保存到切片和文件夹中。在
发生图像保存的Python代码段。在
from PIL import Image
...
...
i = 0
new_img = Image.fromarray(bounding_box_img) ## conversion to an image
new_img.save("slicedhand/{}#sliced_image{}.jpeg".format(threadname, i))
我想问题可能出在权限访问上。医生说要用--key_file
。但是我应该使用什么样的密钥文件以及在哪里可以找到它。我不清楚这是问题还是其他问题。在
任何帮助都将不胜感激。在
我知道您正在Linux虚拟机实例上使用gcfuse来访问Google云存储。在
密钥文件是一个服务帐户凭据密钥,它允许您将Cloud SDK或客户端库作为另一个服务帐户启动。You can download key file from Cloud Console。但是,如果您使用的是VM实例,那么您将自动使用计算引擎默认服务帐户。您可以使用控制台命令进行检查:
$ gcloud init
。在到configure properly your credentials, please follow the documentation。在
计算引擎默认服务帐户,需要有enabled Access Scope Storage > Full。访问范围是限制对云API的访问级别的机制。这可以在计算机创建期间或VM实例停止时完成。在
请注意,Access Scopes是为VM实例选择的服务帐户显式定义的。在
相关问题 更多 >
编程相关推荐