Any gcloud Command Fails With ImportError: No module named __future__ Mac [duplicate]

↘锁芯ラ 提交于 2019-12-11 06:59:24

问题


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

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