質問

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!

役に立ちましたか?

解決

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.

他のヒント

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

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

I'm not sure if you have the same problem as mine. But for what I did, I open command prompt, and install the gsutil by using pip command (make sure pip and python installed).

pip install gsutil

Then, try run the gsutil after installation.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top