Reputation: 1293
When installing gcloud for mac I get this error when I run the install.sh
command according to docs here:
Traceback (most recent call last):
File "/path_to_unzipped_file/google-cloud-sdk/bin/bootstrapping/install.py", line 8, in <module>
from __future__ import absolute_import
I poked through and echoed out some stuff in the install shell script. It is setting the environment variables correctly (pointing to my default python installation, pointing to the correct location of the gcloud SDK).
If I just enter the python interpreter (using the same default python that the install script points to when running install.py
) I can import the module just fine:
>>> from __future__ import absolute_import
>>>
Only other information worth noting is my default python setup is a virtual environment that I create from python 2.7.15 installed through brew. The virtual environment python bin is first in my PATH so python
and python2
and python2.7
all invoke the correct binary. I've had no other issues installing packages on this setup so far.
If I echo the final line of the install.sh script that calls the install.py script it shows /path_to_virtualenv/bin/python -S /path_to_unzipped_file/google-cloud-sdk/bin/bootstrapping/install.py
which is the correct python. Or am I missing something?
Upvotes: 1
Views: 2116
Reputation: 11
In google-cloud-sdk/install.sh
go to last line, remove variable $CLOUDSDK_PYTHON_ARGS
as below.
"$CLOUDSDK_PYTHON" $CLOUDSDK_PYTHON_ARGS "${CLOUDSDK_ROOT_DIR}/bin/bootstrapping/install.py" "$@"
"$CLOUDSDK_PYTHON" "${CLOUDSDK_ROOT_DIR}/bin/bootstrapping/install.py" "$@"
Upvotes: 1
Reputation: 183
I had the error below when trying to run gcloud commands.
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/gcloud.py", line 20, in <module>
from __future__ import absolute_import
ImportError: No module named __future__
If you have your virtualenv
sourced automatically you can specify the environment variable CLOUDSDK_PYTHON
i.e. set -x CLOUDSDK_PYTHON /usr/bin/python
to not use the virtualenv
python
.
Upvotes: 2
Reputation: 1123072
The script uses the -S
command-line switch, which disables loading the site
module on start-up.
However, it is a custom dedicated site
module installed in a virtualenv that makes a virtualenv work. As such, the -S
switch and virtualenvs are incompatible, with -S
set fundamental imports such as from __future__
break down entirely.
You can either remove the -S
switch from the install.bat
command or use a wrapper script to strip it from the command line as you call your real virtualenv Python.
Upvotes: 4