问题
I'm on MacOS. My default python is a virtual environment created from a brew install of Python 2.7.15. My PATH
is set up so that the venv is the default python
and python2.7
. I had some issues installing gcloud that have been resolved and I have successfully installed gcloud.
However, any time I try to run any gcloud
command I still get the same ImportError I was seeing upon install.
Traceback (most recent call last):
File "/path_to_gcloudsdk/google-cloud-sdk/lib/gcloud.py", line 20, in <module>
from __future__ import absolute_import
ImportError: No module named __future__
Additional Info Per Comment Requests:
Output when I enter my default python's interpreter and run import sys; print(sys.path)
:
[
''
'/path_to_virtual_env/lib/python27.zip'
'/path_to_virtual_env/lib/python2.7'
'/path_to_virtual_env/lib/python2.7/plat-darwin'
'/path_to_virtual_env/lib/python2.7/plat-mac'
'/path_to_virtual_env/lib/python2.7/plat-mac/lib-scriptpackages'
'/path_to_virtual_env/lib/python2.7/lib-tk'
'/path_to_virtual_env/lib/python2.7/lib-old'
'/path_to_virtual_env/lib/python2.7/lib-dynload'
'/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7'
'/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin'
'/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk'
'/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac'
'/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages'
'/path_to_virtual_env/lib/python2.7/site-packages'
]
回答1:
Ended up being the same issue I was running into with the install. The google-cloud-sdk/bin/gcloud
shell script used the -S
flag to run gcloud.py
.
I edited the shell script so that it does not add any python args and now it all works fine.
Thanks again @Martijn Pieters for bumping me in the right direction
来源:https://stackoverflow.com/questions/54448868/any-gcloud-command-fails-with-importerror-no-module-named-future-mac