`cannot find package "appengine" error` when using VS code - google-app-engine

By following this tutorial I created a go lang project and opened it by Visual Studio Code.
The code itself works fine I can run the server, but somehow VS Code shows
cannot find package "appengine" in any of:
/usr/local/Cellar/go/1.8.3/libexec/src/appengine (from $GOROOT)
/Users/ironsand/go/src/appengine (from $GOPATH)
I thought I must set GOROOT for the Google App Engine, but according to this stackoverflow question I shouldn't.
How to make VS Code recognize google app engine library properly?
More info
The appengine package exists in ~/dev/google-cloud-sdk/platform/google_appengine/goroot-1.8/‌​src/appengine
I'm using macOS Sierra 10.12.6.

I did use that tutorial and it's working on my Mac via terminal and via VS Code.
You may follow this tutorial to be able use VS code to deploy GAE app with python:
Deploy GAE app with VS code
• Dont forget to update path of dev_appserver.py in tasks.json.
If that didn't work out, you would need to re-install/init google-cloud-sdk.
Note that it's necessary to provide root privileges during installing/initializing in order to allow installer script to add paths properly.
Last thing: avoid tilde expansion ~ in path. Use absolute path in config.( in general absolute path must be used always unless there is a reason to use relative address with tilde )
Good luck,'.

Related

Using go delve with google app engine standard & dev_appserver.py

In the google release notes it says:
November 15, 2017
Go runtime notes
Updated Go SDK to 1.9.61
Add --go_debugging flag to dev_appserver.py to enable Delve debugging.
I'm using dev_appserver.py to fire up several services simultaneously, so that they all share the same datastore emulator, and it works great.
However, when I add that --go_debugging flag, I get lots of errors which I don't understand. If anyone has insight, I'd be grateful.
I get these kinds of errors for each service it tries to build:
can't load package: package -N: unknown import path "-N": cannot find module providing package -N
can't load package: package -l: unknown import path "-l": cannot find module providing package -l
Is there maybe a problem with launching several services at once?
Thanks!
Update Nov 2020:
With all the new changes to app engine being able to use standard go libraries at google APIs, now I can just run my go app locally without using dev_appserver, and let it attach to my local datastore emulator etc. Because of that, and thanks to vscode, delve debugging works great (with the go extension). So now I can step through my app engine standard go code.

How to copy an exe file to App Engine (flex) with Go runtime?

My Go application needs to use a stand-alone executable, which I would like to copy it along with 'gcloud app deploy' command during deployment to GAE flex environment.
I have tried keeping the exe in the folder where other go files are located during deploy, but this doesn't seem to take the exe to the GAE flex
I tried using these 2 lines in Dockerfile and changed the "runtime: custom" in app.yaml, but that didn't fix either, as I am missing few more things it seems.
FROM gcr.io/google-appengine/golang
ADD test.exe /usr/local/bin/
Can anyone suggest, without/with Dockerfile, how can I copy the test.exe and also build the go application on a GAE flex environment?
EDIT:
I realize I should install the package (Debian package) on the GAE machine itself, and make it available for the App Engine app.
Any pointers on how to prepare the Dockerfile so that the Debian package is installed with all its dependencies and is also accessible to the app that I am deploying to App Engine?
You can copy a file using the command COPY.
However, it will not work, since the VM running the GAE flex instance uses Linux as seen in StackOverflow.
I also found this related thread, it may be helpful for you.
EDIT
Other options you have to deploy your application, which is in need of a windows executable file, is to create a VM instance with Windows and deploy your application there. Or you could find an alternative for that stand-alone executable for Linux, perhaps?

Running GAE GCS on PyCharm under OS X, runtime error "No module named cloudstorage"

I am trying to add Google Cloud Storage functionality to a Python GAE app that is already running with significant functionality. I work entirely within PyCharm on my development computer, which is a Mac running OS X 10.9.5.
I have created a new Python module that contains this statement:
import cloudstorage as gcs
as shown in the sample code at https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/getstarted
When I first added that line, PyCharm said "No module named cloudstorage" in the editor.
I then followed both the "pip" and the "svn" instructions at https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/download
to download the GCS Client Library.
In trying to follow those instructions, taking into account my prior experience with this programming environment, I actually tried using "pip" three times:
Once without the "-t" option, since I've never needed that option with "pip" before
Once using the "-t" option to specify my application directory's "lib" subdirectory
Once using:
pip install GoogleAppEngineCloudStorageClient -t /Applications/GoogleAppEngineLauncher.app//Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib, since I wasn't sure what the instructions meant by "<your_app_directory/lib>"
As mentioned, I also executed the "svn" command. Then, as mentioned in install python google cloud storage client on Ubuntu 14.04, I ran "cd gcs-client/src" and "sudo python setup.py install". I ran these commands in my user root directory.
After each of those successful but different installations of the GCS Client Library, I looked at the PyCharm editor window for my module, and it always had the same "No module named cloudstorage" error. But as an experiment, I would also try restarting PyCharm, and also try running my app.
At some point, the editor window stopped showing the error. It was not immediately after one of those steps above, but after I would go away to read various webpages and then come back to look at the error again. I don't know which of the installations was the one that got rid of the error message in the PyCharm editor.
In any case, whenever I try to run the app (again, inside PyCharm), I always get the runtime error "ImportError: No module named cloudstorage" on the same import statement.
The Run/Debug Configuration page for this app has both "Add content roots to PYTHONPATH" and "Add source roots to PYTHONPATH" checked.
Of course the main help I want is how to get past the "No module named cloudstorage" runtime error, even though the import statement no longer shows an error.
I think I also have as many as three spurious versions of the GCS Client Library. I'm much more concerned with getting past "Module not found", since it's a show-stopper, but if you have any idea how I can delete the spurious versions so that they're not just lying around, I'd be most grateful for that help as well.
If the "cloudstorage" directory is at <app>/lib/cloudstorage, then the import statement has to specify "lib":
import lib.cloudstorage
In my case, it's:
import lib.cloudstorage as gcs
By the way, the <app>/lib/GoogleAppEngineCloudStorageClient-1.9.5.0-py2.7.egg-info directory does not seem to be needed and can be deleted.
Actually, you also need to
touch __init__.py
in the lib directory. This will make the cloudstorage module visible to the "import lib.cloudstorage" command.
Dear Google: The distributions should include this file (or the procedure should account for it), and the demo script should be changed to reflect the expected usage. But more importantly why are you distributing/PROLIFERATING library code like this??!!! Why is this not distributed via gcloud? How am I ever going to pick up a patch for this library?
The accepted answer's solution
import lib.module_name
definitely can solve the problem. But I don't like add lib in front of every single module and happened to see how Google suggest import third party libs like this.
appengine will automatically run a file called appengine_config.py. So you can create such a file and put
from google.appengine.ext import vendor
vendor.add('lib')
inside that file. This will help you tell appengine to find dependencies in that folder, so you can simply write
import cloudstorage as gcs
I solve the missing module issue by adding the following to my main application file (main.py):
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "lib"))
I think this is the way Guido intended. Now my code simply says import cloudstorage as gcs. None of the lib.cloudstorage or lib/__init__.py business.
From
https://stackoverflow.com/a/37645984/1740008

Which version of Eclipse works with PHP Google App Engine?

I've search in vain for about a month now and I can't get my PHP application pushed to Google App Engine, for the PHP platform. I've got the Java version set up nicely on my computer. I followed the instructions for GAE PHP here: https://developers.google.com/appengine/docs/php/gettingstarted/introduction
..but it's really confusing because it essentially tells me to install Eclipse made for PHP which is Luna, but the only versions of Eclipse that GAE supports is Kepler, Juno and Indigo (https://developers.google.com/eclipse/docs/getting_started), so I'm super confused.
I don't think you can install two different GAE plugins on a standard version of Eclipse (which is what I use for the Java GAE plugin).
I also tried (in vain, but it was worth a shot) to upload my app using my Java plugin/setup and obviously this was a terrible idea because all it does is just print the php script/code to the browser.
Any thoughts, brothas/sistas?
I have figured out how to push php files to GAE. There are essentially 3 ways.
Use appcfg.py. Run following command:
--appcfg.py update helloworld/, where helloworld is replaced by the name of the folder containing your project files. Make sure the path is relative to appcfg.py directory or an absolute path.
--Enter your Google username and password at the prompts.
**2. Use the App Engine Launcher, probably found in C:\Program Files (x86)\Google\google_appengine\launcher. Executable is called GoogleAppEngineLauncher.exe. Simply select the project in Launcher and click Deploy.
**3. Use Git. Create a local repository on your machine. Add a repo to your Github account, and follow these instructions: https://developers.google.com/appengine/docs/push-to-deploy#creating_a_cloud_project
**4. Use PhPStorm. Download PHPStorm for free for 30 days, or buy a student version/whatever version you quality for here: . Then follow these instructions: http://confluence.jetbrains.com/display/PhpStorm/Getting+Started+with+PhpStorm+as+Google+App+Engine+PHP+IDE. The only thing I haven't figured out is #5 - where to find the php-cgi.exe file. I can't provide a path for a file I don't have.
** denotes super easy and I have used successfully.
The Google Plugin for Eclipse is only for Java applications. For PHP applications, you'll want to use the Python/PHP SDK and either the command-line tools or the Launcher UI app for running the development server. You can still use Eclipse for editing your PHP source files.
RE #5 - "I can't provide a path for a file I don't have".
That was also my problem.
They are fond of pointing out that the SDK directory should contain dev_appserver.py and ‘google’ and ‘php’ packages but you don't find those in a simple search cause they are invisible. You have to muck through the installation directory.

Failed to initialize App Engine SDK 1.8.9

I am using Indigo on a Mac Pro (10.9.1). I updated to Java1.7 in order to run some updated Google Play Service samples. Under Installed JREs, JAVA7 is shown as the only and default choice, which points to the new Java path. But when I start Eclipse, it started complaining that "JRE version is 1.6.0; version 1.7.0 or later is needed to run Google plugin for Eclipse".
I tried to add the vm option in eclipse.ini, i.e. I added
-vm
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/home/bin/java
above "-vmargs" as described here: http://wiki.eclipse.org/Eclipse.ini.
It doesn't make any difference though. Since then, I have uninstalled GPE from Eclipse and installed them again via "install new software" from https://dl.google.com/eclipse/plugin/3.7. Still the same problem. Under Google->App Engine, there is an error message "Failed to initialize App Engine SDK (path)". This points to appengine-java-sdk-1.8.9.
I have checked my Java version using all means I am aware of, i.e. from run Java -version, using Java's control panel, output from code... They all show I am using Java 1.7.0.51.
Any help is appreciated!
Edit: Google has provided a solution that works great. Add this argument in eclipse.ini
-vm
/Library/Java/JavaVirtualMachines/jdk1.7.0_WHATEVERTHESUFFIXIS/Contents/Home/jre/lib/server/libjvm.dylib
Make sure that eclipse Is compiling your project to 1.7 specifications. Even though you have 1.7 selected as your virtual machine, it might be compiling to 1.6. It's in the eclipse project settings

Resources