I am trying to download the latest version of one of my existing google appengine projects & I am tired of seeing the errors! I am running the appcfg.py command inside the google sdk python 2.7 dir. Here's what I ran.
python "C:\DEV_Tools\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\appcfg.py" download_app -A <project> -V <version> C:\DEV_Tools\Dump\
Output :
Traceback (most recent call last):
File "C:\DEV_Tools\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\appcfg.py", line 133, in <module>
run_file(__file__, globals())
File "C:\DEV_Tools\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\appcfg.py", line 129, in run_file
execfile(_PATHS.script_file(script_name), globals_)
File "C:\DEV_Tools\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\appcfg.py", line 66, in <module>
from google.appengine.api import appinfo
File "C:\DEV_Tools\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\api\appinfo.py", line 54, in <module>
from google.appengine.api import validation
File "C:\DEV_Tools\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\api\validation.py", line 46, in <module>
from google.appengine._internal.ruamel import yaml
File "C:\DEV_Tools\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\_internal\ruamel\yaml\__init__.py", line 85, in <module>
from google.appengine._internal.ruamel.yaml.main import * # NOQA
File "C:\DEV_Tools\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\_internal\ruamel\yaml\main.py", line 19, in <module>
from google.appengine._internal.ruamel.yaml.loader import BaseLoader, SafeLoader, Loader, RoundTripLoader # NOQA
File "C:\DEV_Tools\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\_internal\ruamel\yaml\loader.py", line 10, in <module>
from google.appengine._internal.ruamel.yaml.constructor import (
File "C:\DEV_Tools\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\_internal\ruamel\yaml\constructor.py", line 21, in <module>
from google.appengine._internal.ruamel.yaml.comments import * # NOQA
File "C:\DEV_Tools\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\_internal\ruamel\yaml\comments.py", line 642, in <module>
class CommentedMap(MutableMapping, ordereddict, CommentedBase):
File "C:\DEV_Tools\Google\Python27\lib\abc.py", line 86, in __new__
cls = super(ABCMeta, mcls).__new__(mcls, name, bases, namespace)
TypeError: Error when calling the metaclass bases
Cannot create a consistent method resolution
order (MRO) for bases CommentedBase, MutableMapping, ordereddict
There could be an issue with the installed files on your system. I have tried to reproduced the issue however I got different kind of error:
Traceback (most recent call last): File "C:\Program Files
(x86)\Google\google_appengine\appcfg.py", line 133, in
run_file(file, globals()) File "C:\Program Files
(x86)\Google\google_appengine\appcfg.py", line 129, in run_file
execfile(_PATHS.script_file(script_name), globals_) NameError: name
'execfile' is not defined
This was due to corrupted installation files. I have completely reinstalled Google App Engine Python SDK and it worked for me. Try the steps below as it might help you as well:
Downloading Source code from GAE:
It only works for App Engine Standard apps
You can confirm that as in you Google Cloud Console where you choose the version of a specific service. The dropdown menu Tools will not give option Source for Flex apps but only for Standard apps
You should have Python version 2.7 installed
You should have latest version of App Engine SDK for Python
Steps:
Go to the Control Panel > Programs & Features and uninstall your Google App Engine SDK.
Go to the path where GAE was installed and delete the google_appengine folder. In your occasion it is C:\DEV_Tools\Google\Cloud SDK\google-cloud-sdk\platform
Install Python 2.7 from here
Install and initialize Google Cloud SDK from Quickstart for Windows
Run Google Cloud SDK as administrator and execute $ gcloud init
Then execute $ gcloud config set project [PROJECT_ID] based on gcloud config set doc.
Execute $ gcloud components install app-engine-python to install GAE Python based on Download the Cloud SDK
Execute $ gcloud components install app-engine-python-extras to install extras.
Execute $ gcloud components update to update the components.
Install GAE SDK for Python as it is mentioned in Download and install the original App Engine SDK for Python
Restart your computer
Run Google Cloud SDK as Administrator
Execute the command $ gcloud info to verify that the correct project and correct user account is setup.
If it is not setup properly the execute $ gcloud init and set up properly to authenticate the SDK.
Execute appcfg.py -A [PROJECT_ID] -V [VERSION_NAME] download_app C:\PATH\TO\SAVE\SOURCE_CODE Make sure that the version is referring to an GAE STANDARD app
It will redirect you to an browser page so you could login with the same account that you set up the SDK for authentication.
You should see:
Authentication successful.
04:37 PM Fetching files...
04:37 PM [1/16] WEB-INF/lib/_ah_compiled_jsps-0000.jar
04:37 PM [2/16] WEB-INF/lib/org.apache.taglibs.taglibs-standard-impl-1.2.5.jar
04:37 PM [3/16] WEB-INF/min-quickstart-web.xml
04:37 PM [4/16] WEB-INF/appengine-generated/app.yaml
04:37 PM [5/16] WEB-INF/lib/org.eclipse.jdt.ecj-3.14.0.jar
04:37 PM [6/16] WEB-INF/web.xml
04:37 PM [7/16] WEB-INF/lib/org.mortbay.jasper.apache-el-8.5.24.2.jar
04:37 PM [8/16] WEB-INF/lib/org.mortbay.jasper.apache-jsp-8.5.24.2.jar
04:37 PM [9/16] source-context.json
04:37 PM [10/16] WEB-INF/quickstart-web.xml
04:38 PM [11/16] WEB-INF/classes/source-context.json
04:38 PM [12/16] WEB-INF/lib/org.apache.taglibs.taglibs-standard-spec-1.2.5.jar
04:38 PM [13/16] WEB-INF/appengine-web.xml
04:38 PM [14/16] WEB-INF/lib/org.eclipse.jetty.apache-jsp-9.4.14.v20181114-nolog
Otherwise if it is GAE Flex you will see this error:
54319 download_app C:\PATH\TO\SAVE\SOURCE_CODE 04:38 PM Host:
appengine.google.com 04:38 PM Fetching file list... Error 400: ---
begin server output --- Major version "[VERSION_NAME]" does not exist.
--- end server output ---
Related
When starting the local development server with dev_appserver.py i get the following error.
$ dev_appserver.py app.yaml
INFO 2017-07-03 06:51:09,662 devappserver2.py:116] Skipping SDK update check.
Traceback (most recent call last):
File "/home/daniel/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 103, in <module>
_run_file(__file__, globals())
File "/home/daniel/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 97, in _run_file
execfile(_PATHS.script_file(script_name), globals_)
File "/home/daniel/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 381, in <module>
main()
File "/home/daniel/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 369, in main
dev_server.start(options)
File "/home/daniel/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 176, in start
configuration.modules[0].application_root, datastore_emulator_host)
File "/home/daniel/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/api_server.py", line 524, in create_api_server
appidentity_oauth_url=options.appidentity_oauth_url)
File "/home/daniel/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/api_server.py", line 699, in setup_stubs
oauth_url=appidentity_oauth_url)
File "/home/daniel/google-cloud-sdk/platform/google_appengine/google/appengine/api/app_identity/app_identity_stub.py", line 198, in Create
import six
File "/home/daniel/google-cloud-sdk/platform/google_appengine/lib/six-1.9.0/six/__init__.py", line 825, in <module>
from . import test_six
File "/home/daniel/google-cloud-sdk/platform/google_appengine/lib/six-1.9.0/six/test_six.py", line 105, in <module>
#py.test.mark.parametrize("item_name",
AttributeError: 'NoneType' object has no attribute 'parametrize'
Version:
$ gcloud --version
Google Cloud SDK 161.0.0
app-engine-python 1.9.55
beta 2017.03.24
bq 2.0.24
core 2017.06.26
gcloud
gsutil 4.26
The gcloud-sdk component app-engine-python==1.9.55 vendored six==1.9.0 library seems to be dependent on pytest.
Issue is fixed by installing pytest
$ pip install pytest
See issue: https://issuetracker.google.com/issues/62980070
This should only be an issue for users who have a pytest version < 2.2.0 installed locally, where the current version is 3.1.3. Users will not see this issue if either (a) they do not have pytest installed or (b) have pytest >= 2.2.0 installed. The #py.test.mark.parametrize() decorator at the end of the stack trace was introduced in 2.2.0.
We've submitted a patch that resolves this for users of pytest < 2.2.0 that will be available in the next App Engine SDK release. In the meantime, users can upgrade their pytest version locally and the issue should go away.
I have installed the latest version of google cloud sdk, google-cloud-sdk-app-engine-python on my Ubuntu PC as mentioned in the docs in-order to test google-cloud-endpoints-framework sample app.
But on invoking an api request, I got the below traceback. Seems like there is a conflict between google package inside GAE sdk and the google package installed automatically to the lib folder because of google-endpoints package.
$ dev_appserver.py app.yaml
INFO 2017-03-14 07:51:36,173 devappserver2.py:764] Skipping SDK update check.
INFO 2017-03-14 07:51:36,199 api_server.py:268] Starting API server at: http://localhost:44561
INFO 2017-03-14 07:51:36,213 dispatcher.py:199] Starting module "default" running at: http://localhost:8080
INFO 2017-03-14 07:51:36,213 admin_server.py:116] Starting admin server at: http://localhost:8000
INFO 2017-03-14 07:51:45,811 module.py:806] default: "GET /_ah/start HTTP/1.1" 404 -
ERROR 2017-03-14 07:51:45,877 wsgi.py:263]
Traceback (most recent call last):
File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/home/gemini/gae projects/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/main.py", line 19, in <module>
import endpoints
File "/home/gemini/gae projects/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/__init__.py", line 29, in <module>
from apiserving import *
File "/home/gemini/gae projects/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/apiserving.py", line 74, in <module>
from google.api.control import client as control_client
File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 1001, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named google.api
I tried creating a seperate virtualenv but the problem still exists.
Here is the reply from a google guy..
Local development with endpoints framework v2 isn't currently supported, you'll need to deploy the app.
https://github.com/GoogleCloudPlatform/python-docs-samples/issues/853
Your error :
ImportError: No module named google.api
So you need first to install gcloud python module and google-api-python-client module with:
pip install --upgrade gcloud
pip install --upgrade google-api-python-client
from here
I had a similar issue with other Google packages in my lib directory.
I solved/monkey patched it using the following code in my appengine_config.py file:
import sys
import os
import google
from google.appengine.ext import vendor
lib_directory = os.path.dirname(__file__) + "<relative path to lib dir>"
google.__path__.append(os.path.join(lib_directory, 'google'))
logging.info("importing lib %s" % (lib_directory))
vendor.add(lib_directory)
I am trying to connect to the Google App Engine Datastore from my local machine. I have spent all day digging in to this without any luck.
I have tried the approach here (as well as alot of other suggestions from SO such as Using gcloud-python in GAE and Unable to run dev_appserver.py with gcloud):
How to access a remote datastore when running dev_appserver.py?
I first installed gcloud based on this description from google:
https://cloud.google.com/appengine/docs/python/tools/using-libraries-python-27
According to the description I should add the following to my appengine_config.py:
from google.appengine.ext import vendor
vendor.add('lib')
If I do that I get an error saying ImportError: No module named gcloud
If I then move the code to my main.py it seems to pickup the lib-folder and the modules there. That seems a bit strange to me, since I thought appengine_config was being run first to make sure things were initialised.
But now I am getting the following stack trace:
ERROR 2016-09-23 17:22:30,623 cgi.py:122] Traceback (most recent call last):
File "/Users/thomasd/Documents/github/myapp/main.py", line 10, in <module>
from gcloud import datastore
File "/Users/thomasd/Documents/github/myapp/lib/gcloud/__init__.py", line 17, in <module>
from pkg_resources import get_distribution
File "/Users/thomasd/Documents/github/myapp/lib/pkg_resources/__init__.py", line 2985, in <module>
#_call_aside
File "/Users/thomasd/Documents/github/myapp/lib/pkg_resources/__init__.py", line 2971, in _call_aside
f(*args, **kwargs)
File "/Users/thomasd/Documents/github/myapp/lib/pkg_resources/__init__.py", line 3013, in _initialize_master_working_set
dist.activate(replace=False)
File "/Users/thomasd/Documents/github/myapp/lib/pkg_resources/__init__.py", line 2544, in activate
declare_namespace(pkg)
File "/Users/thomasd/Documents/github/myapp/lib/pkg_resources/__init__.py", line 2118, in declare_namespace
_handle_ns(packageName, path_item)
File "/Users/thomasd/Documents/github/myapp/lib/pkg_resources/__init__.py", line 2057, in _handle_ns
loader.load_module(packageName)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 246, in load_module
mod = imp.load_module(fullname, self.file, self.filename, self.etc)
File "/Library/Python/2.7/site-packages/google/cloud/logging/__init__.py", line 18, in <module>
File "/usr/local/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 999, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named google.cloud.logging.client
What am I doing wrong here?
The google-cloud library is not working on App Engine and most likely you don't even have to since you can use the build in functionality.
From the official docs you can use it like this:
import cloudstorage as gcs
I solved it this way:-
1.) Create a lib folder in your project path.
2.) Install gcloud libraries by running following command into terminal from your project path:-
pip install -t lib gcloud
3.) Create an appengine_config.py module in your project and add following lines of code:-
import sys
import os.path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'lib'))
4.) After this, you can import like this:-
from gcloud import datastore
5.) To save data into live google datastore from local:-
client = datastore.Client("project-id")
key = client.key('Person')
entity = datastore.Entity(key=key)
entity['name'] = ashish
entity['age'] = 23
client.put(entity)
It will save an entity named Person having properties name and age. Do not forget to specify your correct project id.
Old question but this may be worth including:
I'm unsure the state of your requirements.txt file but I scrounged mine a bit and noticed setuptools was not included.
pip freeze doesn't export setuptools related question
Assuming you're following the tutorial, you likely installed those libraries EXCEPT for setuptools to lib.
I added setuptools=={verionnumber} to requirements.txt and that fixed this related issue for me.
I've been following this tutorial here in an attempt to build an app on Google app engine:
https://github.com/GoogleCloudPlatform/appengine-django-skeleton
I've hit a brick wall though in that when I run dev_appserver.py, 2 out of 3 servers run fine. But the development server just returns 500 errors.
The exact console output is the following:
ubuntu#ubuntu:~/Desktop/appengine-django-skeleton$ dev_appserver.py --port=9999 app.yaml
INFO 2015-12-15 15:50:11,507 sdk_update_checker.py:229] Checking for updates to the SDK.
INFO 2015-12-15 15:50:11,691 sdk_update_checker.py:257] The SDK is up to date.
INFO 2015-12-15 15:50:11,807 api_server.py:205] Starting API server at: http://localhost:60930
INFO 2015-12-15 15:50:11,993 dispatcher.py:197] Starting module "default" running at: http://localhost:9999
INFO 2015-12-15 15:50:11,993 admin_server.py:116] Starting admin server at: http://localhost:8000
ERROR 2015-12-15 15:50:16,395 wsgi.py:263]
Traceback (most recent call last):
File "/home/ubuntu/Desktop/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/home/ubuntu/Desktop/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/home/ubuntu/Desktop/google_appengine/google/appengine/runtime/wsgi.py", line 96, in LoadObject
__import__(cumulative_path)
File "/home/ubuntu/Desktop/appengine-django-skeleton/mysite/wsgi.py", line 29, in <module>
application = get_wsgi_application()
File "/home/ubuntu/Desktop/appengine-django-skeleton/lib/django/core/wsgi.py", line 13, in get_wsgi_application
django.setup()
File "/home/ubuntu/Desktop/appengine-django-skeleton/lib/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/ubuntu/Desktop/appengine-django-skeleton/lib/django/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/home/ubuntu/Desktop/appengine-django-skeleton/lib/django/django/apps/config.py", line 131, in create
"'%s' isn't a subclass of AppConfig." % entry)
ImproperlyConfigured: 'django.contrib.admin.apps.AdminConfig' isn't a subclass of AppConfig.
And I'm guessing that the key line here is
ImproperlyConfigured: 'django.contrib.admin.apps.AdminConfig' isn't a subclass of AppConfig.
No code changes have been made to the file from github. Only the configuration changes listed on the github page.
I have manged to solve this problem by installing all the modules required on virtualenv not inside the lib directory. After cloning the repository, run this command.
pip install -r requirements.txt
Recently, I have updated Google App Engine from 1.9.17 to 1.9.18 via Google Cloud SDK by using command 'gcloud components update' in Windows 7 64 bit. After that I wasn't able to start any project using the App Engine launcher. Getting this error:
Traceback (most recent call last):
File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\dev_appserver.py", line 83, in <module>
_run_file(__file__, globals())
File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\dev_appserver.py", line 79, in _run_file
execfile(_PATHS.script_file(script_name), globals_)
File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 36, in <module>
from google.appengine.tools.devappserver2 import dispatcher
File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\dispatcher.py", line 29, in <module>
from google.appengine.tools.devappserver2 import module
File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\module.py", line 71, in <module>
from google.appengine.tools.devappserver2 import vm_runtime_factory
File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\vm_runtime_factory.py", line 25, in <module>
from google.appengine.tools.devappserver2 import vm_runtime_proxy
File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\vm_runtime_proxy.py", line 29, in <module>
from google.appengine.tools.devappserver2 import log_manager
File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\log_manager.py", line 34, in <module>
from google.appengine.tools.docker import containers
File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\docker\containers.py", line 47, in <module>
import docker
ImportError: No module named docker
2015-03-05 19:11:27 (Process exited with code 1)
I even installed the latest Google Cloud SDK, but I'm getting the same error.
I'm able to install the appengine SDK 1.9.18(without using Google Cloud SDK) and able to run the project successfully.
This error is happening only for the App Engine launcher installed via Google Cloud SDK in Windows 7.
This issue is raised in App Engine Issue Tracker: Issue 125. I recommend you to star this issue.
This has happened to me today to reinstall the app engine sdk. I could not run my code in the launcher.
I remember reading that is not used pip app engine, but now I have solved the problem.
In short what I did was:
Install pip the footsteps of https://pip.pypa.io/en/latest/installing.html (this also correctly install the setuptools)
Install docker-py by pip: pip install docker-py and ready, I can now run my code in the launcher
P.S.
Previously I tried to install the docker-py package, downloaded from https://github.com/docker/docker-py, but lacked setuptools, downloaded and installed the package did not work. So use this with pip.
This is currently an issue with the dev_appserver bundled in the Cloud SDK. A fix will be out soon. In the meanwhile, your options are:
1) Use gcloud preview app run to run your app when using the Cloud SDK
2) Install the standalone AppEngine SDK (which you already mentioned in your question)
If installing docker-py doesn't work and the stacktrace shows that the error line is:
from docker import docker
Change this line to:
import docker
Source
Jumping on the answer from #Tzach and adding some info.
The file to modify is containers.py
for me it is located here :
C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\docker
If you can't modify it because the file is open in an application, it is in fact that the folder is protected. Just copy/paste the file on your desktop and modify it from there. then copy it back in the original folder.