3
votes

I am trying to download some samples from Google storage to do a sentiment analysis. I am following the instructions but get an error (I actually added a destination file to their instruction and the error is different):

Error as defined by Google on example: Jorge:python3.7 jbp$ gsutil cp gs://cloud-samples-tests/natural-language/sentiment-samples.tgz CommandException: Wrong number of arguments for "cp" command. Traceback (most recent call last): File "", line 1, in File "/Users/jbp/Python/env/lib/python3.7/google-cloud-sdk/platform/gsutil/gslib/init.py", line 29, in import tempfile File "tempfile.py", line 39, in import functools as _functools File "functools.py", line 8 SyntaxError: Non-ASCII character '\xc5' in file functools.py on line 8, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details Jorges-MBP:python3.7 jbarrigapartarrieu$

Error with destination file: Jorge:python3.7 jbp$ gsutil cp gs://cloud-samples-tests/natural-language/sentiment-samples.tgz /User/jbp/Python Copying gs://cloud-samples-tests/natural-language/sentiment-samples.tgz... OSError: Permission denied. KiB]
Traceback (most recent call last): File "", line 1, in File "/Users/jbarrigapartarrieu/Python/env/lib/python3.7/google-cloud-sdk/platform/gsutil/gslib/init.py", line 29, in import tempfile File "tempfile.py", line 39, in import functools as _functools File "functools.py", line 8 SyntaxError: Non-ASCII character '\xc5' in file functools.py on line 8, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

3

3 Answers

3
votes

Adding sudo to the line solved my problem

sudo gsutil cp gs://cloud-samples-tests/natural-language/sentiment-samples.tgz ./
0
votes

It looks like the user executing the gsutil command doesn't have permission to write to /User/jbp/Python or the path doesn't exist.

On a linux system, you can check the path's permissions and owner(s) using namei:

namei -mo /User/jbp/Python

Alternativelly, try saving the file to your working directory:

 gsutil cp gs://cloud-samples-tests/natural-language/sentiment-samples.tgz ./
0
votes

It looks like you're somehow invoking gsutil with Python 3, which is not supported yet. The line below the import tempfile statement (which is failing) in gslib/__init__.py would have raised this error, but it looks like it didn't even get that far:

https://github.com/GoogleCloudPlatform/gsutil/blob/9ac524d7f4424ae8c92f001b46f5c1cf2ae68b8d/gslib/init.py#L31