3

在 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
4

5 回答 5

5

直接原因可能是记忆力不足。升级前尝试添加交换。

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
于 2017-09-04T00:49:25.350 回答
4

我在运行 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
于 2017-02-18T16:23:02.107 回答
0

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

原因:

安装了较旧的 Python 包。

我想这是一个旧的dnspython

如果你使用点子:

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

所有 pip 包都将更新

如果使用easy_install需要手动检查

于 2017-10-22T20:08:37.207 回答
0

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

apt-get autoremove

由于该软件包是已删除的python-dialog,因此我猜这是问题所在……至少对我而言。:-)

编辑:

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

于 2017-06-12T18:44:48.347 回答
-1

遵守以下命令

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

sudo rm /usr/bin/click

纠正损坏的库

sudo apt autoremove -f click

更新和升级库

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

sudo dpkg --configure -a

于 2019-12-15T18:47:53.987 回答