任何gcloud命令失败并出现ImportError:没有名为__future__ Mac的模块

时间:2019-01-30 20:15:37

标签: python google-cloud-platform gcloud google-cloud-sdk

我在MacOS上。我的默认python是从Python 2.7.15的现成安装创建的虚拟环境。我的PATH已设置为venv是默认的pythonpython2.7。我在安装have been resolved的gcloud时遇到了一些问题,并且我已经成功安装了gcloud。

但是,每次尝试运行任何gcloud命令时,我仍然会收到与安装时相同的ImportError。

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__

每个评论请求的其他信息:

输入默认的python解释器并运行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 个答案:

答案 0 :(得分:0)

最终与安装时遇到的问题相同。 google-cloud-sdk/bin/gcloud shell脚本使用-S标志来运行gcloud.py

我编辑了shell脚本,以便它不添加任何python args,现在一切正常。

再次感谢@Martijn Pieters向正确的方向撞我