I have a python GAE application, with an ndb datastore storing images as a blob property.
I use get_serving_url() function to serve images, and it works properly on the Google App Engine production server ("my-app".appspot.com).
When i try it on localhost, the URL seems to be generated correctly, but if I click on it I receive a blank page.
Is it normal, because GAE does not implement it on localhost, or it's a problem of my development environment? Anyway: is there a way to make it works on localhost? I didn't find any information on the web.
Thank you.
update
Some additional details: all the upload process work correctly, I see the uploaded image in the blobstore viewer, and its url is something like localhost:8000/*blob-key*?display=inline.
When i call get_serving_url() on localhost, i obtain an url like localhost:8080/_ah/img/*blob-key* and it does not work (blank page). I just discovered that on Log Console I receive this message:
ERROR 2013-12-30 11:52:14,299 module.py:665] Request to '/_ah/img/vMDNz9x9ak9VcjBXmfMBcg==' failed
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\module.py", line 661, in _handle_request
return handler.handle(match, environ, wrapped_start_response)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\wsgi_handler.py", line 59, in handle
return self._wsgi_app(environ, start_response)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\blob_image.py", line 195, in call
return self.serve_image(environ, start_response)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\blob_image.py", line 184, in serve_image
image, mime_type = self._transform_image(blobkey, options)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\blob_image.py", line 68, in _transform_image
image = _get_images_stub()._OpenImageData(image_data)
AttributeError: 'ImagesNotImplementedServiceStub' object has no attribute '_OpenImageData'
Anyway, when i deploy on the production server, the get_serving_url() produce something like lh6.ggpht.com/*longer-blob-key* that points on Google servers and works correctly.
You need to install PIL to make it working on your local machine.
Install PIL from https://developers.google.com/appengine/docs/python/images/installingPIL
I solved the issue updating Google App Engine.
Now I have the release 1.9.15 and don't have the problem anymore.
Related
I've been running app engine local development server from the command prompt for 3 years without any issues (windows 7, 64bit). I just updated to v1.9.36 (download 960cfe2157c6e984802db4b0224cfe8273d727dc from this page), and now when I run
dev_appserver.py [anything]
I get:
Traceback (most recent call last): File "C:\Program
Files\Google\Cloud
SDK\google-cloud-sdk\platform/google_appengine\dev_appserver.py", line
82, in
_run_file(file, globals()) File "C:\Program Files\Google\Cloud
SDK\google-cloud-sdk\platform/google_appengine\dev_appserver.py", line
78, in _run_file
execfile(_PATHS.script_file(script_name), globals_) File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\tools\devappserver2\devappserver2.py",
line 37, in
from google.appengine.tools.devappserver2 import dispatcher File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\tools\devappserver2\dispatcher.py",
line 29, in
from google.appengine.tools.devappserver2 import module File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\tools\devappserver2\module.py",
line 55, in
from google.appengine.tools.devappserver2 import http_runtime File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\tools\devappserver2\http_runtime.py",
line 53, in
import portpicker ImportError: No module named portpicker
The strange thing is that if I use the SDK GUI, and hit the 'Run' button, it launches just fine, no errors. So my guess is that when running from the command line, it's using the version of 'dev_appserver.py' in the Cloud SDK folder, whereas the GUI is running the version in C:\Program Files (x86)\Google\google_appengine\. But my environment variables are:
GAE_SDK_ROOT: C:\Program Files (x86)\Google\google_appengine
PATH: lots of other things, plus C:\Program Files (x86)\Google\google_appengine\
And I dont see any reference to Cloud SDK, so I cant figure why the version in the folder would be run.
There are versions of dev_appserver.py in both C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine and C:\Program Files (x86)\Google\google_appengine
Seems that in combining GAE SDK with Google Cloud, Google has made this more complicated than it used to be..
[UPDATE]
If I run echo %PATH% then among many other things, I see
C:\Program Files\Google\Cloud SDK\google-cloud-sdk..
before
C:\Program Files (x86)\Google\google_appengine\
Which explains why it's running that version. The question now is: why is the former in my PATH if I havent set it in my user PATH variable? Where else is the Windows PATH manipulated? Presumable the Google Cloud SDK installer did this - how do I undo it?
Executing dev_appserver.py [anything] will launch the first dev_appserver.py executable encountered in your executable PATH environment, which appears to be not the one you expect :)
You have 2 options:
update your PATH as needed
execute the desired dev_appserver.py by specifying its full path:
C:\Program Files (x86)\Google\google_appengine\dev_appserver.py [anything]
This answer is somehow related: appcfg.py not working in command line
New answer
I turns out that the Cloud SDK folder was in my system path, which is checked before the user path, so the version of dev_appserver.py in Cloud SDK was being executed, rather than the more up to date version in the app engine folder.
To fix this I simply removed the Cloud SDK from my system path, using the handy app detailed here
Original answer
I worked out that if I rename the Cloud SDK folder in C:\Program Files\Google this fixes it. But that's a hacky fix, and presumably makes the Cloud SDK functionality unavailable (I dont think I currently need it).
So I'd still like a proper answer to this question. It seems that I need a way to control which version of dev_appserver.py gets run, and short of setting my environment variables (which I've already done) I dont know what else to try.
As an alternative to the other answers, if you do not have the old standalone Google App Engine installed and only uses the Google SDK, you can also install portpicker with the following command line (assuming you have pip installed):
pip install portpicker
I have followed all the steps on https://cloud.google.com/appengine/docs/go/#creating_a_simple_http_handler on how to get started with Go, but I am stuck on an issue while trying to run the helloworld app.
I get the following error:
C:\Users\kirill\Desktop\go_appengine>goapp serve myapp
Traceback (most recent call last):
File "C:\Users\kirill\Desktop\go_appengine\\dev_appserver.py", line 83, in <module>
_run_file(__file__, globals())
File "C:\Users\kirill\Desktop\go_appengine\\dev_appserver.py", line 79, in _run_file
execfile(_PATHS.script_file(script_name), globals_)
NameError: name 'execfile' is not defined
error while running dev_appserver.py: exit status 1
Go AppEngine SDK requires Python 2.7 (Python 3.x cannot be used). It looks to me your SDK is using Python 3.X or you don't have Python at all (in your PATH).
First make sure Python 2.7 is added to your PATH so that will be used by goapp. You can get it here: Python 2.7.11. For the Go AppEngine SDK a small, portable Python is also enough, you can get it from here: Single-File Stand-alone Python 2.7.9 for Windows. Download pyexe-2.7.9.10.zip and extract it. It's just a 10 MB single file, rename it to python.exe and add it to your PATH.
Also going further, it looks to me you are starting your Hello world app from the wrong folder: you are standing in the SDK's folder, and you want to start it specifying that your app is in the myapp subfolder inside your SDK, which is unlikely.
Navigate to the folder where you app is (app.yaml must be there). In that folder execute the command
goapp serve
This will start the app being in the current folder. For this to work, the goapp command (goapp.bat on windows) must be added to your PATH.
If you can't or don't want to add your go_appengine folder to your PATH, still navigate to the folder containing the app you want to start, but provide the path for goapp, e.g.
C:\Users\kirill\Desktop\go_appengine\goapp serve
I've just stumbled upon similar issue myself, In Python 3
Instead of
execfile("./filename")
Use
exec(open("./filename").read())
For the past few days I have been trying to trace the source of the error shown in the blockquote in trying to deploy an app to google app engine on a windows machine using the command:
> gcloud preview app deploy app.yaml
Beginning deployment... Verifying that Managed VMs are enabled and
ready.
Traceback (most recent call last): ...
File "C:\Program Files\Google\Cloud
SDK\google-cloud-sdk\bin.../lib\docker\docker\tls.py", line 46, in
init
'Path to a certificate and key files must be provided'
TLSParameterError: Path to a certificate and key files must be
provided through the client_config param. TLS configurations should
map the Docker CLI client configurations.
Does anyone have any idea on how to solve this issue?
FYI: I have already set the environment variables DOCKER_CERT_PATH, DOCKER_TLS_VERIFY and DOCKER_HOST as set by Docker.
I'm using some in-house tool to upload a config file. But I get the following error:
Jan 10, 2013 11:18:58 AM com.google.appengine.tools.development.LocalResourceFileServlet doGet
WARNING: No file found for: /content/xxx.xml
Where xxx.xml is the file that I've uploaded. Any hints as to what this erorr means? The class LocalResourceFileServlet does not even seem to be present with my vesion of appengine. My hunch is telling me to edit web.xml but I'm not sure...
Any help/hints would be appreciated.
GAE has a read-only filesystem. So you can not upload a file to appengine and then access it via a direct url. You can only access files that were uploaded as part of the project upload.
However, you can upload file to GAE Blobstore and then access ti via your own handler - see Blobstore docs for examples.
I'm trying to switch my app engine app from python 2.5 to 2.7 and urlfetch.fetch() just doesn't want to work (on the dev server at least; I haven't deployed it yet). If I do something as simple as:
file = urlfetch.fetch(url="http://www.google.com")
I get the following error:
File "C:\workspace\DjangoServer\src\mycode.py", line 167, in request
file = urlfetch.fetch(url="http://www.google.com")
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\urlfetch.py", line 264, in fetch
return rpc.get_result()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py", line 592, in get_result
return self.__get_result_hook(self)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\urlfetch.py", line 366, in _get_fetch_result
raise DownloadError(str(err))
DownloadError: ApplicationError: 2 [Errno 11003] getaddrinfo failed
Searching the internet has suggested it might be a firewall or proxy issue, but I turned off the firewall and I'm not behind a proxy.
This works fine in the python 2.5 dev server, but not the python 2.7 dev server. If I open a python 2.7 console and manually runsocket.getaddrinfo("www.google.com", 80) it works there as well.
Any ideas? Has anyone else encountered this?
Ok, I have been able to reproduce this issue and after a lot of going back and forth in git from a version that was working to a version that was not working I found that (at least in my case) the problem was in django-nonrel (because I updated all at once: django-nonrel and appengine).
So, please do the following: edit djangoappengine/settings_base.py and change
try:
from google.appengine.api import apiproxy_stub_map
except ImportError:
from .boot import setup_env
setup_env()
from djangoappengine.utils import on_production_server, have_appserver
to:
from djangoappengine.utils import on_production_server, have_appserver
if not on_production_server:
from .boot import setup_env
setup_env()
The real issue seems to be that in a previous version of django-nonrel, the import was actually written as: from google.appengine.api import api_proxy_stub_map (which was never found and the setup_env() was always called), so, when the import was fixed, the setup_env() was no longer called (which in my case made the error appear).
A 2nd note is that for some reason this was only happening when running inside of Eclipse/PyDev and it did work on the command line (although the environment variables seemed the same for me, so, I'm unsure why running from inside java actually made a difference).