Cloud storage client libraries not working. No module appengine.api - google-app-engine

I'm trying to set up the cloud storage client libraries so I can store images for my gae app using python. I'm following the instructions here:
https://cloud.google.com/storage/docs/reference/libraries
Unfortunately when I import the storage module:
from google.cloud import storage
something goes wrong saying:
ImportError: No module named appengine.api
Is there a way i can check if I have appengine.api installed at all (which I believe i do. It should have been included in the app engine sdk i installed)? If it's not installed how can I install it?

The GCS library is not included the GAE SDK, it has to be vendored in as a 3rd party lib.
See also Downloading the client library in the GAE Setting Up Google Cloud Storage doc.

Related

No module named 'google.appengine' from within Cloud Shell

I'm testing Google App Engine and trying to run a simple function to upload files to either the Blobstore or Cloud Storage. I'm typing the Python code directly in the Cloud Shell of my instance. The code is failing when I call:
from google.appengine.ext import blobstore
I get the error code:
Traceback (most recent call last):
File "upload_test.py", line 1, in <module>
from google.appengine.api import users
ImportError: No module named 'google.appengine'
Even though the documentation says that: You can use Google Cloud Shell, which comes with git and Cloud SDK already installed, I've tried installing a bunch of libraries:
gcloud components install app-engine-python
pip install google-cloud-datastore
pip install google-cloud-storage
pip install --upgrade google-api-python-client
I'm still getting the same error. How can I get the appengine library to work? Alternatively, is this the wrong method for creating an app that allows the user to upload files?
The google.appengine module is baked into the first-generation Python (2.7) runtime. It's not available to install via pip, in the second-generation (3.7) runtime, or in Cloud Shell.
The only way to use it is by writing and deploying a first-generation App Engine app.
Thanks #Dustin Ingram
I found the answer in this page.
The current "correct" way of uploading to Cloud Storage is to use google.cloud.storage. The tutorial I linked above explains how to implement it.
The impression I have, however, is that this uses twice the bandwidth as the solution via google.appengine. Originally, the front-end would receive an upload url and send the file directly to the Blobstore (or to Cloud Storage). Now the application uploads to the back-end which, in turn, uploads to Cloud Storage.
I'm not too worried, as I will not be dealing with excessively large files, but it seems strange that the ability to upload directly has been discontinued.
In any case, my problem has been solved.

Google cloud Appengine standard environment deployment using Admin API: "Cant find import" Error

I am trying to deploy a simple "hello world" application in Appengine standard - Go environment. There is one source file hello.go with one import "google.golang.org/appengine"
I followed the documentation here to use the Admin API for deployment. But I got "can't find import: google.golang.org/appengine" error when I checked the status of the deployment.
So I uploaded the google.golang.org library folder to Cloud Storage, but documentation seems to only show how to include single files separately from GCS buckets, which is not feasible for big imported libraries.
I know all this will work with "gcloud app deploy", but I have to use the Admin API and standard environment.
Is there a way to tell Appengine to "go get" imported libraries?
Is there a way to include folders (not single files) from GCS bucket in
deployment config files?
The deployment works with gcloud because the appengine library is present in your GOPATH. gcloud fetches them from there.
In the case of the deployment using Admin API, in order to not include one per one all files from your libraries, the packages need to be present in Google Cloud Storage for ZIP deployment or you can use Cloud Source Repositories, build it with the CREATE call and then deploy it from a container with the Cloud Build image.

Does my PHP project need appengine-web.xml

Setting up IntelliJ IDEA to run my PHP Wordpress (for App Engine) projects. Google Cloud Tools installed.
Have imported existing project files and then went to Tools > Google Cloud Tools > Run on a local App Engine Standard dev server.
An error is returned:
Project does not contain App Engine Standard modules: To use the App Engine Standard local development server, the project must contain at least one App Engine Standard module with an appengine-web.xml configuration file.
I read up on appengine-web.xml and apparently its used for Java projects. I'm trying to run PHP at the moment.
I haven't dealt with this file type before, is it similar to app.yaml?
Do I need this fie to set up my local server for PHP?
Actually the file appengine-web.xml corresponds to the App Engine Java runtime, you don't need to use it in your PHP project. It is similar to the app.yaml in the sense that it is where you define your default service.
In order to define the default service in your PHP app, you need the app.yaml. There are also optional configuration files, such as:
dispatch.yaml, queue.yaml, index.yaml, cron.yaml, dos.yaml
On a side note, maybe PHP Storm or Eclipse with the PHP Development tools are more suitable for your use case.

ImportError: cannot import name CredentialsNDBProperty

using appengine and Ferris, I am receiving this error when trying to use bulkloader.yaml.
from oauth2client.appengine import CredentialsNDBProperty, StorageByKeyName
ImportError: cannot import name CredentialsNDBProperty
Have you this problem only when your code is deployed ?
In localhost, if you have oauth2client installed into python/site-package, AppEngine devserver use it. But when you deploy your application on App Engine, you need to embed this library in your project.
The list of third-party libraries include into App Engine python runtime : https://developers.google.com/appengine/docs/python/tools/libraries27

Can't import library into Google App Engine project

I use the Google App Engine SDK 1.8.5 with Eclipse 3.8 on Ubuntu.
I want to add the Cloud Storage service to my app, so I downloaded guava-gwt-15.0.jar and appengine-gcs-client-0.3.jar, and put them in my apps /war/WEB-INF/lib/ folder. I also added these jars to the build path in Eclipse.
When I fire up my app in dev mode, it runs fine, at least until I try to access a page relevant to the GCS library. When I do that, I get the following error:
java.lang.NoClassDefFoundError: com/google/common/base/Preconditions
at com.google.appengine.tools.cloudstorage.GcsServiceImpl.<init>(GcsServiceImpl.java:35)
at com.google.appengine.tools.cloudstorage.GcsServiceFactory.createGcsService(GcsServiceFactory.java:32)
... etc
I cleaned my project and restarted Eclipse multiple times, and still the problem persists. What to do?
In addition to Guava for GWT, you also need the core Guava library (guava-15.0.jar). Download the .jar to war/WEB-INF/lib and add it to you build path as well.

Resources