Xcode Update brach gcloud und gsutil

Oct 07 2020

Vor ein paar Stunden ich Xcode auf die neueste Version aktualisiert, die verursacht gcloudund gsutilArbeitsbefehle zu stoppen. Beispielsweise gsutil -m rsyncfunktionierte der Befehl eine Minute vor Abschluss des Updates einwandfrei.

Beim Schreiben dieser Frage habe ich festgestellt, dass ich nicht mehr gitarbeite.

Kann mir bitte jemand erklären, was zum Teufel jetzt passiert ist, da ich kein Python-Typ bin? Ich würde gerne Hilfe bekommen.

python -VAusgabe ist Python 2.7.16.

python3 -VAusgabe ist Python 3.9.0.

pip -V Ausgabe ist pip 20.2.3 from /Users/<MY_USER>/Library/Python/2.7/lib/python/site-packages/pip (python 2.7)

pip3 -V Ausgabe ist pip 20.2.3 from /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip (python 3.9)

Dafür bekomme ich gcloud help:

Traceback (most recent call last):
  File "/Users/<MY_USER>/gcloud/sdk/lib/gcloud.py", line 104, in <module>
    main()
  File "/Users/<MY_USER>/gcloud/sdk/lib/gcloud.py", line 62, in main
    from googlecloudsdk.core.util import encoding
  File "/Users/<MY_USER>/gcloud/sdk/lib/googlecloudsdk/__init__.py", line 23, in <module>
    from googlecloudsdk.core.util import importing
  File "/Users/<MY_USER>/gcloud/sdk/lib/googlecloudsdk/core/util/importing.py", line 23, in <module>
    import imp
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/imp.py", line 23, in <module>
    from importlib import util
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/util.py", line 2, in <module>
    from . import abc
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/abc.py", line 17, in <module>
    from typing import Protocol, runtime_checkable
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/typing.py", line 26, in <module>
    import re as stdlib_re  # Avoid confusion with the re we export.
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/re.py", line 124, in <module>
    import enum
  File "/Users/<MY_USER>/gcloud/sdk/lib/third_party/enum/__init__.py", line 26, in <module>
    spec = importlib.util.find_spec('enum')
AttributeError: module 'importlib' has no attribute 'util'

Und dafür bekomme ich gsutil help:

Traceback (most recent call last):
  File "/Users/<MY_USER>/gcloud/sdk/bin/bootstrapping/gsutil.py", line 13, in <module>
    import bootstrapping
  File "/Users/<MY_USER>/gcloud/sdk/bin/bootstrapping/bootstrapping.py", line 32, in <module>
    import setup  # pylint:disable=g-import-not-at-top
  File "/Users/<MY_USER>/gcloud/sdk/bin/bootstrapping/setup.py", line 57, in <module>
    from googlecloudsdk.core.util import platforms
  File "/Users/<MY_USER>/gcloud/sdk/lib/googlecloudsdk/__init__.py", line 23, in <module>
    from googlecloudsdk.core.util import importing
  File "/Users/<MY_USER>/gcloud/sdk/lib/googlecloudsdk/core/util/importing.py", line 23, in <module>
    import imp
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/imp.py", line 23, in <module>
    from importlib import util
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/util.py", line 2, in <module>
    from . import abc
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/abc.py", line 17, in <module>
    from typing import Protocol, runtime_checkable
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/typing.py", line 26, in <module>
    import re as stdlib_re  # Avoid confusion with the re we export.
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/re.py", line 124, in <module>
    import enum
  File "/Users/<MY_USER>/gcloud/sdk/lib/third_party/enum/__init__.py", line 26, in <module>
    spec = importlib.util.find_spec('enum')
AttributeError: module 'importlib' has no attribute 'util'

Antworten

11 ronen3 Oct 07 2020 at 17:02

Nach fast einem Tag ohne Erfolg fand ich eine Lösung: Ich musste eine Umgebungsvariable mit dem Namen CLOUDSDK_PYTHONauf setzen /usr/bin/python.

Ich habe meine bearbeitet .zprofileund hinzugefügt:

export CLOUDSDK_PYTHON="/usr/bin/python"

Ich habe immer noch keine Ahnung, was es verursacht hat, daher freue ich mich über eine Erklärung, wenn sich jemand die Zeit nehmen möchte.