Installing gsutil on Windows

北慕城南 提交于 2019-12-02 01:07:54

问题


I'm relatively new to python so apologies if this is a dumb question.

I'm having trouble installing gsutil on Windows

I'm following the directions here

https://developers.google.com/storage/docs/gsutil_install#specifications

I've had to install python 2.7 and unzip gsutil in C:\gsutil\gsutil

the directions say to run the following code in the python command prompt

python gsutil

I'm getting this error

  File "<interactive input>", line 1
  python gsutil
              ^
  SyntaxError: invalid syntax

Thanks in advance!


回答1:


What you want to do is find where "python.exe" and "gsutil.py" sit on your local system, like

C:\Python27\python.exe
C:\gsutil\gsutil\gsutil.py

So hit Win+R, cmd, Enter to get into a command prompt, and do a

cd C:\Python27

Then you want to call the python interpreter on the gsutil.py file, like

python.exe C:\gsutil\gsutil\gsutil.py <COMMAND HERE>

And it should work. For your initial configuration, you would run:

python.exe C:\gsutil\gsutil\gsutil.py config -b

And a web-browser would pop open for completing the setup. There are some other nuances, but mostly "python.exe C:\gsutil\gsutil\gsutil.py COMMAND" is an exact replacement for "gsutil COMMAND" including all flags, so a long command like:

type my_list_to_upload.txt | python.exe C:\gsutil\gsutil\gsutil.py -m cp -I gs://.../ > output.txt

Will work.




回答2:


It looks like you're running the command from the python shell. You want to run it from the Windows command-line prompt.




回答3:


After installing Python 2.7 and extracting gsutil.zip to your C drive, create a little batch script with these two lines:

@echo off
C:\Python27\python.exe C:\gsutil\gsutil.py %*

Put it in a folder like C:\Users\You\bin and add that folder to your PATH variable.

Now you can use gsutil from anywhere in your Windows CMD



来源:https://stackoverflow.com/questions/20446464/installing-gsutil-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!