- Installed the Google Cloud Python Debugger tool
- Lets me debug issues on my server-side code
- Why? A friend found a bug, and I couldn’t find source of issue on server.
- Google’s Python Cloud Debugger is in alpha stage! It’s very buggy
- Installation required a day’s worth of troubleshooting
A buddy was helping test out the site for me. He ran into an error after submitting his payment details. He said his browser would just refresh after clicking ‘submit.’
I checked the logs on my server in console.cloud.google.com, and saw that there was a simple KeyError for my dictionary.
This type of issue is easy to debug on my computer. However, I had already tested this out locally, and the data passed back shouldn’t be missing the <code>token_id</code> key.
Google thankfully has been developing a debugger tool for our web applications hosted on their servers. However, it was a mission to set it up, since support for Python 3.7 is still in alpha and very buggy. Here’s a breakdown of my issues and how I resolved them:
- Server runtime environment is Python 3.7. In my app.yaml file, the first line is <code>runtime: python37</code>
- My local virtual environment is Python 3.7. All of my libraries were installed with this Python version.
- Issue: From their PYPI page, google-python-cloud-debugger only officially supports Python 2.7 and Python 3.6.
Issues I encountered:
Issue: Trying to pip install google-python-cloud-debugger. But keep getting this message:
“Could not find a version that satisfies the requirement google-python-cloud-debugger (from versions: ) No matching distribution found for google-python-cloud-debugger”
Resolved: According to documentation, google-python-cloud-debugger only works for Python 2.7 or Python 3.6. BUT, some parts of the documentation mention that it supports Python 3.7 as well.
I tried 2 things:
Install the Python 3.7 version (didn’t work)
- I noticed that I could manually download the .egg file for the Python 3.7 version and install it myself. I followed instructions here: https://github.com/GoogleCloudPlatform/cloud-debug-python#installation. I copied the files to my local lib folder, and deployed the app. Didn’t work. I’m still getting this issue, even after I installed the google-python-cloud-debugger:
- I wonder if it’s because I didn’t include it in my requirements.txt file? I previously did, but came up with the same issue of copying it into the library. Maybe I should manually copy it?
- OK, I manually copied google-cloud-debugger from /anaconda3/envs/<venv>/lib/python3.7/site-packages/google_python_cloud_debugger-py3.7-linux-x86_64.egg/googleclouddebugger
- to my lib folder.
- Didn’t seem to work. Still have the same message as above.
Create a Python 3.6 virtual environment (worked)
- Create a new virtual environment on Python 3.6 and pip install the Google Cloud Debugger tool from there. Did that. But question was, do I have to change my runtime environment to Python 3.6 too?
- OK, changed runtime to Python 3.6. Deployed to Google App Engine.
- Got this error message: ERROR: (gcloud.app.deploy) INVALID_ARGUMENT: Invalid runtime ‘python36’ specified. Accepted runtimes are: [go, php, php55, python27, java, java7, java8, go111, nodejs8, nodejs10, php72, python37]
- Maybe I need to have a flex environment? Let’s try with 37 first.
- I changed my app.yaml file from runtime: python36 to runtime: python37. It uploaded with no issue. But will it work?
- Yes! It does.
Question for another day: I’m using different Python versions across various environments. How do they relate to each other?
- burningvpn-venv (Anaconda virtual environment) = v3.7
- app.yaml = `runtime: python37`
- google-python-cloud-debugger = python v3.6
Great, now to ask my friend to try and re-create that bug. Thanks Eddie!
Other cool thing I learned: you can run Flask on Visual Studio Code! And you get the entire debugging environment there too. Along with breakpoints, etc.