简体   繁体   English

如何在Google Cloud Storage上运行Python脚本?

[英]How to run Python script on Google Cloud storage?

I am trying to run a Python script on files in Google Cloud Storage (without using the google-cloud-storage package). 我正在尝试对Google云端存储中的文件运行Python脚本(不使用google-cloud-storage包)。 I have Jupyter running on a VM instance. 我在虚拟机实例上运行Jupyter。 How can I access my files from Jupyter? 如何从Jupyter访问我的文件? this is an example of the code I'm trying to run: 这是我尝试运行的代码的示例:

    fileName = 'OUTCAR'

    with open(fileName) as file:
        for line in file:
            if 'free  energy   TOTEN' in line:
                print(line)

After the last comment, I might know what you can do. 在最后一条评论之后,我可能知道您可以做什么。 At the end, it comes to what you want to try to do. 最后,涉及您想尝试做的事情。 To "see" a bucket as a local volume, you could use gcsfue to mount GCS as volume on your VM. 要将存储桶“视为”本地卷,可以使用gcsfue将GCS作为卷挂载到VM上。 At that point you will see files as local. 届时,您将看到本地文件。 However they are not really local file gcsfue manages downlaod, upload, and update for you. 但是,它们并不是gcsfue真正为您管理下载,上载和更新的本地文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM