Reputation: 1986
As announced today in Production Troubleshooting with Cloud Debugger now available for Python, supposedly I can use Python Debugger now.
I am running AppEngine Managed VMs on GCE images, so am following the guide for Setting up Python on Compute Engine. I have modified my Dockerfile to add pip install google-python-cloud-debugger
(I've also tried installing the library directly into my app/lib, which is included in my sys.path):
FROM gcr.io/google_appengine/python-compat
RUN pip install google-python-cloud-debugger
ADD . /app
And then I have modified my main.py to enable the debugger:
try:
import googleclouddebugger
googleclouddebugger.AttachDebugger()
except ImportError:
pass
Unfortunately, when I commit the code, run gcloud preview app gen-repo-info-file
, and push it, I cannot use the debugger. When I go to https://console.developers.google.com/debug, it loads my github repository on the right, but I see an error message in the left-hand nav area:
Debugging is not available. You can debug Java applications running on App Engine or Compute Engine
Any ideas what might be going wrong, or how to debug the debugger?
Upvotes: 1
Views: 558
Reputation: 468
The easiest way to check that the Python Cloud Debugger is properly installed is to try importing it in Python interactive console:
docker run -i -t cdbgtest bin/bash
python
import googleclouddebugger
print googleclouddebugger.__version__
My guess is that in your case pip install google-python-cloud-debugger
fails. If that's the case, it's probably due to outdated pip
. Installing pip
with sudo easy_install pip
would solve it.
Upvotes: 0
Reputation: 3591
EDIT: Although this answer's thread contains useful debugging steps, the root cause of the issue is explained in my other posted answer.
It's likely two things are happening here:
The first is that your pip command, running as a normal user, wants to access the system install location and fails without root privileges. Try sudo pip install...
or pip install -t lib/ google-python-cloud-debugger
.
The second thing that's happening is that your code is catching an ImportError and merely pass
ing. I've seen that construction before in my life as a python-speaker, and honestly it's a foot-shotgun if I ever saw one. What purpose could pass
serve? An error log quickly shows the issue if you take such a precaution.
Upvotes: 0
Reputation: 3591
Although the other thread did provide a lot of opportunity to follow common best-practices in debugging, the solution is a lot simpler than either of us had imagined. It's likely that the errors you're seeing are a result of the fact that Managed VMs with python is not yet a supported platform for Cloud Debugger, according to the documentation.
However, with the growth of the Cloud Debugger service, and the fact that Cloud Debugger with python at all was just announced on the 7th, it's certainly possible that this will change.
Feel free to file Feature Requests in the Cloud Platform Public Issue Tracker if you notice something missing and would like to let us know that it's an interest to you and others who might star the issue.
Upvotes: 1