Acabo de actualizar Fedora 32 a Fedora 33 (que viene con Python 3.9). Desde entonces, el comando gcloud dejó de funcionar:
[guy@Gandalf32 ~]$ gcloud Error processing line 3 of /home/guy/.local/lib/python3.9/site-packages/XStatic-1.0.2-py3.9-nspkg.pth: Traceback (most recent call last): File "/usr/lib64/python3.9/site.py", line 169, in addpackage exec(line) File "<string>", line 1, in <module> File "<frozen importlib._bootstrap>", line 562, in module_from_spec AttributeError: 'NoneType' object has no attribute 'loader' Remainder of file ignored Traceback (most recent call last): File "/usr/lib64/google-cloud-sdk/lib/gcloud.py", line 104, in <module> main() File "/usr/lib64/google-cloud-sdk/lib/gcloud.py", line 62, in main from googlecloudsdk.core.util import encoding File "/usr/lib64/google-cloud-sdk/lib/googlecloudsdk/__init__.py", line 23, in <module> from googlecloudsdk.core.util import importing File "/usr/lib64/google-cloud-sdk/lib/googlecloudsdk/core/util/importing.py", line 23, in <module> import imp File "/usr/lib64/python3.9/imp.py", line 23, in <module> from importlib import util File "/usr/lib64/python3.9/importlib/util.py", line 2, in <module> from . import abc File "/usr/lib64/python3.9/importlib/abc.py", line 17, in <module> from typing import Protocol, runtime_checkable File "/usr/lib64/python3.9/typing.py", line 26, in <module> import re as stdlib_re # Avoid confusion with the re we export. File "/usr/lib64/python3.9/re.py", line 124, in <module> import enum File "/usr/lib64/google-cloud-sdk/lib/third_party/enum/__init__.py", line 26, in <module> spec = importlib.util.find_spec('enum') AttributeError: module 'importlib' has no attribute 'util'Actualizar desde el soporte de GCP
El soporte de GCP mencionó que la nueva versión 318.0.0 lanzada el 2020.11.10 debería ser compatible con Python 3.9
Actualicé mi gcloud sdk a 318.0.0 y ahora parece que Python 3.9.0 es compatible.
Para solucionar este problema, ejecute
gcloud components update
Fedora 33 incluye python 2.7 y para obligar a GCloud SDK a usarlo, configure esta variable de entorno
export CLOUDSDK_PYTHON=python2 Puede agregar este comando de exportación a su ~/.bash_profile
Python 3.9 es muy nuevo y se espera que Gcloud SDK no sea compatible con 3.9, está escrito para ser compatible con 2.7.x y 3.6 - 3.8 (3.8 puede causar algunos problemas de compatibilidad, recomiendo usar 3.7)
Como solución, configure Python 3.8 o 3.7 (estas versiones funcionan bien para Gcloud y la mayoría de las distribuciones de Linux) como intérprete de todo el sistema e intente usar los comandos de gcloud.
Si no desea usar Python 2, puede usar Python 3.8 en Fedora 33 hasta que el SDK comience a admitir Python 3.9.
Instale python 3.8 usando:
sudo dnf install python3.8Puede verificar su instalación ejecutando:
python3.8 --versionLuego configúralo como el intérprete del SDK de Google Cloud:
export CLOUDSDK_PYTHON=python3.8Después de esto, el SDK debería funcionar normalmente.
gcloud se actualizará a la versión 318 el 10 de noviembre y solucionará este problema.
Para macOS/Homebrew:
brew install python@3.8 export CLOUDSDK_PYTHON=python3.8 ln -s /usr/local/Cellar/python@3.8/*/bin/python3.8 /usr/local/bin/python3.8 gcloud components update # the issue is now resolved and you can return to python 3.9 unset CLOUDSDK_PYTHONMe pasó después de una actualización de cerveza. Funciona con Python 3.8.
Necesita hacer python3.8 en su ruta de shell. Ejecuté las siguientes líneas y funcionó.
export PATH="/usr/local/opt/python@3.8/bin:$PATH" alias python=/usr/local/opt/python@3.8/bin/python3¡Gracias!
Para usuarios de Mac OS
En primer lugar, debe ejecutar brew update .
Si tienes este error:
Error: homebrew-core is a shallow clone. To `brew update` first run: git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core" fetch --unshallow This restriction has been made on GitHub's request because updating shallow clones is an extremely expensive operation due to the tree layout and traffic of Homebrew/homebrew-core. We don't do this for you automatically to avoid repeatedly performing an expensive unshallow operation in CI systems (which should instead be fixed to not use shallow clones). Sorry for the inconvenience!Ejecute los siguientes comandos:
git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core" fetch --unshallow git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask" fetch --unshallowAhora,
Actualizar python 3.8 brew upgrade python@3.8
Agregue python 3.8 a PATH export PATH="/usr/local/opt/python@3.8/bin:$PATH"
Usar python 3.8 en la export CLOUDSDK_PYTHON=python3.8
Ahora, puede actualizar los componentes gcloud components update