在postinst配置上升级Ubuntu 16.04上的gcloud失败。已经安装并使用了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
答案 0 :(得分:6)
直接原因可能是缺乏记忆。 尝试在升级之前添加交换。
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
答案 1 :(得分: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
答案 2 :(得分:0)
我所做的就是应用 autoremove 标志,并重新安装自己的固定。在我的小实例上运行它已经花了很长时间,但最终确实有效。
apt-get autoremove
由于包被 python-dialog 被删除,我猜这是问题...至少对我而言。 : - )
由于我的谷歌实例可能是最小的,因此没有足够的内存来完成任务。一旦我停止了Web服务器和所有PM2任务,它最终完成没有错误。
答案 3 :(得分:0)
问题加载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
,则需要手动检查
答案 4 :(得分:0)
对我有用
sudo rm / usr / bin /单击 sudo apt-get autoremove -f单击
sudo apt-get更新&& sudo apt-get安装-f
sudo dpkg --configure -a