安装带有多个版本py2.7的Google Cloud SDK时出现sqlite3错误

问题描述 投票:1回答:1

首次从AWS设置转移到GCE,请善待我的天真问题。

在步骤./google-cloud-sdk/install.sh期间,我遇到以下错误:

  Welcome to the Google Cloud SDK!
  Traceback (most recent call last):
    File "/Users/t/Desktop/./google-cloud-sdk/bin/bootstrapping/install.py", line 8, in <module>
      import bootstrapping
    File "/Users/t/Desktop/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 19, in <module>
      from googlecloudsdk.core.credentials import store as c_store
    File "/Users/t/Desktop/google-cloud-sdk/lib/googlecloudsdk/core/credentials/store.py", line 34, in <module>
      from googlecloudsdk.core.credentials import creds
    File "/Users/t/Desktop/google-cloud-sdk/lib/googlecloudsdk/core/credentials/creds.py", line 40, in <module>
      import sqlite3
    File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
      from dbapi2 import *
    File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/dbapi2.py", line 28, in <module>
      from _sqlite3 import *
  ImportError: No module named _sqlite3

仔细检查后,我注意到我的/usr/local/Cellar/python即有两个python2.7版本。 2.7.10_22.7.11

奇怪的是,当我去python命令行时,这个问题:

  Python 2.7.10 (default, Oct  6 2017, 22:29:07)
  [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
  Type "help", "copyright", "credits" or "license" for more information.

  >>> import sqlite3
  >>> from _sqlite3 import *
  >>> print('hello, this seems to work')
      hello, this seems to work

虽然不幸的是install.sh正在从系统中获取py2.7.11版本而不是python版本,但我不确定我们是否可以设置一些环境变量,(例如在我们开始安装之前的$CLOUDSDK_PYTHON)。

python-2.7 sqlite google-cloud-platform gcloud google-cloud-sdk
1个回答
1
投票

是的,您应该将$ CLOUDSDK_PYTHON环境变量设置为指向正确的Python安装。看到一个类似的问题:google-cloud-sdk installation not finding right Python 2.7 version in CentOS /usr/local/bin

© www.soinside.com 2019 - 2024. All rights reserved.