【问题标题】:Upgrading google-cloud-sdk Fails on Configure配置时升级 google-cloud-sdk 失败
【发布时间】:2017-03-03 00:04:06
【问题描述】:

在 Ubuntu 16.04 上升级 gcloud 在 postinst 配置上失败。 google-cloud-sdk 已安装并使用,没有安装问题,但这会在配置阶段中止升级。问题似乎是 postinst 脚本正在使用 Python2 解释器执行 Python3 脚本,这在 Python3 语法行上失败。


# sudo dpkg --configure google-cloud-sdk
Setting up google-cloud-sdk (131.0.0-0) ...
dpkg: error processing package google-cloud-sdk (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 google-cloud-sdk

dpkg: error processing package google-cloud-sdk (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 google-cloud-sdk


# sudo dpkg --configure -D 777 google-cloud-sdk
D000001: ensure_diversions: new, (re)loading
D000001: process queue pkg google-cloud-sdk:all queue.len 0 progress 1, try 1
D000040: checking dependencies of google-cloud-sdk:all (- <none>)
D000400:   checking group ...
D000400:     checking possibility  -> python2.7
D000400:       checking non-provided pkg python2.7:amd64
D000400:       is installed, ok and found
D000400:     found 3
D000400:   found 3 matched 0 possfixbytrig -
D000040: ok 2 msgs >><<
D000040:     checking Breaks
Setting up google-cloud-sdk (131.0.0-0) ...
D000002: fork/exec /var/lib/dpkg/info/google-cloud-sdk.postinst ( configure 129.0.0-0 )
dpkg: error processing package google-cloud-sdk (--configure):
 subprocess installed post-installation script returned error exit status 1
D000001: ensure_diversions: same, skipping
Errors were encountered while processing:
 google-cloud-sdk


# sudo /usr/bin/gcloud components post-process

Compiling platform/gsutil/third_party/httplib2/python3/httplib2/__init__.py ...
  File "platform/gsutil/third_party/httplib2/python3/httplib2/__init__.py", line 350
    print('%s:' % h, end=' ', file=self._fp)
                        ^
SyntaxError: invalid syntax

ERROR: gcloud crashed (CommandLoadFailure): Problem loading gcloud.dns.record-sets.import: 'module' object has no attribute 'CAA'.

If you would like to report this issue, please run the following command:
  gcloud feedback


# sudo which python; sudo python --version
/usr/bin/python
Python 2.7.12

# sudo which python3; sudo python3 --version
/usr/bin/python3
Python 3.5.2

Trace:
/usr/lib/google-cloud-sdk/gcloud_main.py:130
 gcloud_cli.Execute()
  [...]
/usr/lib/google-cloud-sdk/calliope/backend.py:1630
 resources = command_instance.Run(args)
surface/components/post_process.py:40
 table.Update(self.cli)
/usr/lib/google-cloud-sdk/command_lib/static_completion/table.py:154
 table = CompletionTableGenerator(cli).Wa...
/usr/lib/google-cloud-sdk/calliope/walker.py:98
 root.LoadAllSubElements(recursive=True)
/usr/lib/google-cloud-sdk/calliope/backend.py:1490
 element.LoadAllSubElements(recursive=rec...
/usr/lib/google-cloud-sdk/calliope/backend.py:1490
 element.LoadAllSubElements(recursive=rec...
/usr/lib/google-cloud-sdk/calliope/backend.py:1488
 element = self.LoadSubElement(name)
/usr/lib/google-cloud-sdk/calliope/backend.py:1528
 parent_group=self)
/usr/lib/google-cloud-sdk/calliope/backend.py:1592
 self._GetModuleFromPath(module_dir, modu...
/usr/lib/google-cloud-sdk/calliope/backend.py:1258
 name_to_give, os.path.join(module_dir, *...
/usr/lib/google-cloud-sdk/core/util/pkg_resources.py:108
 module = imp.load_module(name_to_give, f...
surface/dns/record_sets/import.py:19
 from googlecloudsdk.api_lib.dns import i...
/usr/lib/google-cloud-sdk/api_lib/dns/import_util.py:162
 rdatatype.CAA: _CAATranslation,
CommandLoadFailure: Problem loading gcloud.dns.record-sets.import: 'module' object has no attribute 'CAA'.
[output truncated]

# sudo gcloud --version
Google Cloud SDK 131.0.0
alpha 2016.10.17
beta 2016.10.17
bq 2.0.24
bq-nix 2.0.24
core 2016.10.17
core-nix 2016.10.17
gcloud 
gsutil 4.21
gsutil-nix 4.21

【问题讨论】:

    标签: google-cloud-sdk


    【解决方案1】:

    直接原因可能是内存不足。 升级前尝试添加交换。

    sudo dd if=/dev/zero of=/var/swap bs=2048 count=524288
    sudo chmod 600 /var/swap
    sudo mkswap /var/swap
    sudo swapon /var/swap
    sudo apt upgrade
    

    【讨论】:

    • 我没有在 google-cloud-sdk 的后续更新中显式或隐式添加交换或其他任何内容,但最终更新导致它重新开始工作。
    • @Matthew 我知道。我的答案是针对那些有同样问题但仍然受苦的人。
    • 我在 GCE Micro 实例上做事;直到现在,我从未想到它可能内存不足。这解决了一切。 \o/
    • (嗯,几乎所有东西;)
    【解决方案2】:

    我在运行 Ubuntu 16.04 的 Google Compute Engine 实例上遇到了同样的问题,我能够使用以下命令解决它:

    sudo apt-get remove google-cloud-sdk
    export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)"
    echo "deb https://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
    sudo rm /etc/apt/sources.list.d/partner.list
    sudo apt-get install google-cloud-sdk
    

    【讨论】:

    • 是的,我尝试以这种方式删除并重新添加存储库,但没有帮助。只尝试了一些升级,直到它最终奏效。 Google 的团队在票证中做出了回应,但始终无法解释为什么他们的软件试图在 Python 2.7 解释器中运行 Python 3 代码。最终它只是在没有解释的情况下工作。希望不要再发生了。
    • 你需要一个重要的` curl packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key 添加 - ; sudo apt-get update ` 在尝试之前sudo apt-get instal ....
    • @Matthew 你是怎么解决这个错误的,因为同样的错误发生在我身上
    • @twister_void “最终它只是在没有解释的情况下工作。”也许 Stoian 的 curl 成功,我不知道。
    【解决方案3】:

    我所做的只是应用 autoremove 标志,然后它会自行重新安装并自行修复。在我的小实例上运行需要很长时间,但它终于成功了。

    apt-get autoremove
    

    由于包是 python-dialog 已被删除,我猜这是问题所在……至少对我来说是这样。 :-)

    编辑:

    由于我的 google 实例可能是最小的,因此没有足够的内存来完成任务。一旦我停止了 Web 服务器和所有 PM2 任务,它终于没有错误地完成了。

    【讨论】:

      【解决方案4】:

      加载问题gcloud.dns.record-sets.import: 'module' object has no attribute 'CAA'.

      原因:

      已安装较旧的 Python 包。

      我想这是一个旧的dnspython

      如果你使用 pip:

      pip freeze --local | grep -v '^\-e' | cut -d = -f 1  | xargs -n1 pip install -U
      

      所有 pip 包都会更新

      如果你使用easy_install你需要手动检查

      【讨论】:

        【解决方案5】:

        遵守以下命令

        如果您遇到任何锁,请使用“SUDO RM 删除”

        sudo rm /usr/bin/click

        修复损坏的库

        sudo apt autoremove -f click

        更新和升级库

        sudo apt-get update &amp;&amp; sudo apt-get install -f

        sudo dpkg --configure -a

        【讨论】:

        • 它将纠正损坏的库
        • 也许一两个解释性的句子会更好。
        • 没有理由大喊大叫 ;-)
        猜你喜欢
        • 1970-01-01
        • 2021-04-02
        • 2015-01-10
        • 1970-01-01
        • 2020-05-16
        • 1970-01-01
        • 2023-04-02
        • 2020-04-12
        • 1970-01-01
        相关资源
        最近更新 更多