We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
When you use different external tools in the macOS terminal, you'll eventually run into conflicting dependencies. This
is the case when you install Python 3.12 and then try to use gcloud
.
This morning, I was greeted with the following error message:
Traceback (most recent call last):
File "/Users/<username>/google-cloud-sdk-1/lib/gcloud.py", line 137, in <module>
main()
File "/Users/<username>/google-cloud-sdk-1/lib/gcloud.py", line 90, in main
from googlecloudsdk.core.util import encoding
File "/Users/wujames/test-python/google-cloud-sdk-1/lib/googlecloudsdk/__init__.py", line 23, in <module>
from googlecloudsdk.core.util import importing
File "/Users/<username>/google-cloud-sdk-1/lib/googlecloudsdk/core/util/importing.py", line 23, in <module>
import imp
ModuleNotFoundError: No module named 'imp'
After some research, I found that the issue was related to the Python version. I recently installed Python 3.12 and that was causing the issue. The solution was to update the gcloud SDK to use the latest Python version.
That however wasn't so easy as the gcloud tool itself didn't want to start anymore. Thanks to StackOverflow, I was able to find a solution. Here's what I did:
CLOUDSDK_PYTHON=/opt/homebrew/bin/python3.11 gcloud components update
This command tells the gcloud SDK to use the Python 3.11 version. After running this command, the gcloud tool started to update itself to a version that does support Python 3.12.
After the update, I was able to use the gcloud
tool again without any issues. I hope this helps you if you run into the
same issue.
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.