Upgrading google-cloud-sdk Fails on Configure
Asked Answered
G

5

5

Upgrading gcloud on Ubuntu 16.04 fails on postinst configuration. The google-cloud-sdk has been installed and used without installation problems, but this is aborting the upgrade at the configuration phase. The problem seems to be that the postinst script is executing a Python3 script with the Python2 interpreter, which fails on a Python3 syntax line.


# 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
Grecoroman answered 20/10, 2016 at 20:14 Comment(0)
S
6

I encountered the same problem on a Google Compute Engine instance running Ubuntu 16.04, and I was able to resolve it with the following commands:

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
Swihart answered 18/2, 2017 at 16:23 Comment(4)
Yes, I tried removing and re-adding the repo that way, but it didn't help. Only trying for a few upgrades until it finally worked. Google's team was responsive in the ticket, but were never able to explain why their SW was trying to run Python 3 code in a Python 2.7 interpreter. Eventually it just worked without explanation. Hope it doesn't happen again.Grecoroman
You need a vital ` curl packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - ; sudo apt-get update ` before trying sudo apt-get instal ....Louth
@Grecoroman How did you resolved this error , Becuase same error is happening to mePolyclitus
@Polyclitus "Eventually it just worked without explanation." Maybe Stoian's curl hit works, I dunno.Grecoroman
N
5

The direct cause may be a lack of memory. Try to add swap before upgrading.

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
Nonsmoker answered 4/9, 2017 at 0:49 Comment(4)
I didn't add swap or anything else, either explicitly or implicitly within the subsequent updates to the google-cloud-sdk , but eventually an update caused it to start working again.Grecoroman
@Grecoroman I knew that. My answer is for those who have the same issue and still suffers.Nonsmoker
I'm doing things on a GCE Micro instance; it never struck me that it might be insufficient memory until now. This solved everything. \o/Nitriding
(Well, almost everything ;)Nitriding
E
0

All I did was apply the autoremove flag and it reinstalled on its own fixing itself. It took forever to run on my small instance but it did finally work.

apt-get autoremove

Since the package was python-dialog that was removed, I'm guessing that was the issue... at least for me. :-)

Edit:

Since my google instance was the smallest one possible, there was not enough memory to complete the task. Once I stopped the web server and all PM2 tasks, it finally finished without errors.

Exodontist answered 12/6, 2017 at 18:44 Comment(0)
Y
0

Problem loading gcloud.dns.record-sets.import: 'module' object has no attribute 'CAA'.

Cause:

Older Python Packages installed.

I suppose it is an old dnspython

If you use pip:

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

All pip packages will be updated

If you use easy_install you need to check manually

Yawmeter answered 22/10, 2017 at 20:8 Comment(0)
T
-1

adhere following commands

IF YOU COME ACROSS ANY LOCK USE "SUDO RM TO REMOVE

sudo rm /usr/bin/click

RECTIFY THE BROKEN LIBRARIES

sudo apt autoremove -f click

UPDATES & UPGRADES LIBRARIES

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

sudo dpkg --configure -a

Top answered 15/12, 2019 at 18:47 Comment(4)
It will rectify the broken librariesTop
Maybe one or two explaining sentences would be nicer.Sexist
No reason to shout ;-)Sexist
WHY NOT?!?!?!?!Tingey

© 2022 - 2024 — McMap. All rights reserved.