dev_appserver.py not starting development server - python

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

Related

Unable to download google app engine standard project source in Windows 10

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 ---

running dev_appserver.py from linux terminal

I have recently spun up a VM on Google Compute Engine with the view of creating a development environment in the cloud.
I have the source code and install the Google Cloud SDK and the App-Engine SDK. However when i try to run dev_appserver.py I get the following error, even after ensuring firewall rules are created.
x#dev:~/code$ dev_appserver.py --host dev.cfcmelbourne.org --port=8080 cfc/
INFO 2015-05-20 12:54:22,744 sdk_update_checker.py:229] Checking for updates to the SDK.
INFO 2015-05-20 12:54:23,280 sdk_update_checker.py:273] This SDK release is newer than the advertised release.
INFO 2015-05-20 12:54:23,361 api_server.py:190] Starting API server at: http://localhost:38624
INFO 2015-05-20 12:54:23,441 api_server.py:615] Applying all pending transactions and saving the datastore
INFO 2015-05-20 12:54:23,441 api_server.py:618] Saving search indexes
Traceback (most recent call last):
File "/home/xxx/software/google_appengine/dev_appserver.py", line 83, in <module>
_run_file(__file__, globals())
File "/home/xxx/software/google_appengine/dev_appserver.py", line 79, in _run_file
execfile(_PATHS.script_file(script_name), globals_)
File "/home/xxx/software/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 1002, in <module>
main()
File "/home/xxx/software/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 995, in main
dev_server.start(options)
File "/home/xxx/software/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 798, in start
self._dispatcher.start(options.api_host, apis.port, request_data)
File "/home/xxx/software/google_appengine/google/appengine/tools/devappserver2/dispatcher.py", line 189, in start
_module.start()
File "/home/xxx/software/google_appengine/google/appengine/tools/devappserver2/module.py", line 1174, in start
self._balanced_module.start()
File "/home/xxx/software/google_appengine/google/appengine/tools/devappserver2/wsgi_server.py", line 315, in start
self._start_all_fixed_port(host_ports)
File "/home/xxx/software/google_appengine/google/appengine/tools/devappserver2/wsgi_server.py", line 352, in _start_all_fixed_port
raise BindError('Unable to bind %s:%s' % self.bind_addr)
google.appengine.tools.devappserver2.wsgi_server.BindError: Unable to bind dev.cfcmelbourne.org:8080
xxx#dev:~/code$
The firewall rules clear allow 8080 TCP access.
run netstat -tulpn as root user to see if their is a process running on port 8080 . type fuser 8080/tcp to get PID of process running on port 8080 and kill that port or simply use argument -k with fuser command i.e fuser -k 8080/tcp to kill that process. it work fine for me.

Adding Google Analytics API Library to Google App Engine

I am trying to run a simple python script on Google App Engine. How do I install the Google Analytics API library?
Library: https://developers.google.com/api-client-library/python/apis/analytics/v3
Instructions: https://cloud.google.com/appengine/docs/python/tools/libraries27#vendoring
I've tried everything and can't get this to run, even though it works on my pc. What I have right now is:
The python scripts in the root folder,
In the /lib folder I copied the folders that were installed from my PC (/googleapiclient and /google_api_python_client-1.4.0-py2.7.egg-info)
And I have appengine_config.py in /lib folder which contains:
from google.appengine.ext import vendor
# Add any libraries installed in the "lib" folder.
vendor.add('lib')
vendor.add('google-api-client')
app.yaml file:
application: psyched-cab-861
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: hello_analytics_api_v3.app
Traceback:
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
ImportError: No module named helloworld
New Log:
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/lib_config.py", line 354, in __getattr__
self._update_configs()
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/lib_config.py", line 290, in _update_configs
self._registry.initialize()
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/lib_config.py", line 165, in initialize
import_func(self._modname)
File "/base/data/home/apps/s~just-terminus-94303/1.384249106864280829/appengine_config.py", line 5, in <module>
vendor.add('google-api-python-client')
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/vendor/__init__.py", line 44, in add
'No such virtualenv or site directory' % path)
ValueError: virtualenv: cannot access google-api-python-client: No such virtualenv or site directory
I tried editing the appengine_config.py file to
vendor.add('googleapiclient') #The name of the file
I edit it in GAE, and click commit, it saves, but I get the same error as above with the vendor.add('google-api-python-client') error. Why is the file not updating?
As the docs say: put the appengine_config.py in your root folder of the application (and not in the /lib folder).
By the way, the name of the library is google-api-python-client and not google-api-client.
Then you have to install google-python-api-client in your /lib folder:
$ pip install -t lib google-api-python-client

How do I publish a django web app to Google App Engine from Visual Studio 2012

I am trying to set up a django application in Visual Studio 2012 that will publish to Google App Engine. I have a simple hello World Application set up in Visual Studio using pytools that I can run successfully in the development environment.
I added an app.yaml file, downloaded the AppEngine SDK and imported the existing application to the Google App Engine Launcher application. If I start the application locally using the App Engine Launcher, it starts but the page is just an error. I get the following from the log:
2013-05-23 07:47:03 Running command: "['C:\\Python27\\pythonw.exe', 'C:\\Program Files\\Google\\google_appengine\\dev_appserver.py', '--skip_sdk_update_check=yes', '--port=8080', '--admin_port=8000', 'Z:\\gridtreecontrol\\GridTreeView\\GridTreeView']"
INFO 2013-05-23 07:47:09,496 devappserver2.py:522] Skipping SDK update check.
WARNING 2013-05-23 07:47:09,523 api_server.py:329] Could not initialize images API; you are likely missing the Python "PIL" module.
INFO 2013-05-23 07:47:09,543 api_server.py:153] Starting API server at: http://localhost:61149
INFO 2013-05-23 07:47:09,552 dispatcher.py:164] Starting server "default" running at: http://localhost:8080
INFO 2013-05-23 07:47:09,558 admin_server.py:117] Starting admin server at: http://localhost:8000
ERROR 2013-05-23 12:47:32,108 wsgi.py:235]
Traceback (most recent call last):
File "C:\Program Files\Google\google_appengine\google\appengine\runtime\wsgi.py", line 223, in Handle
result = handler(dict(self._environ), self._StartResponse)
File "C:\Program Files\Google\google_appengine\lib\django-1.4\django\core\handlers\wsgi.py", line 219, in __call__
self.load_middleware()
File "C:\Program Files\Google\google_appengine\lib\django-1.4\django\core\handlers\base.py", line 39, in load_middleware
for middleware_path in settings.MIDDLEWARE_CLASSES:
File "C:\Program Files\Google\google_appengine\lib\django-1.4\django\utils\functional.py", line 184, in inner
self._setup()
File "C:\Program Files\Google\google_appengine\lib\django-1.4\django\conf\__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "C:\Program Files\Google\google_appengine\lib\django-1.4\django\conf\__init__.py", line 95, in __init__
raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'settings' (Is it on sys.path?): No module named settings
INFO 2013-05-23 07:47:32,128 server.py:585] default: "GET / HTTP/1.1" 500 -
It seems like it wants me to make some adjustments to sys.path, but I feel like if I did that, it won't propagate those changes to the production server on Google App Engine. I have tried publishing the application to the server, but get the same error there.
I do not get this error when running the application in Visual Studio.
You should not try to develop a standalone Django application and then try to convert it to GAE. There are many differences in running Django inside GAE, and it's best to start from there in the first place.
I don't know why it's important to you to be able to run your app "inside" VS. Again, you should use the GAE development server - you can continue to write your code in VS, and the devserver will even reload when it detects code changes. You might be able to configure VS to use the GAE devserver instead of the Django one, but it sounds like a lot of unnecessary fiddling.

Django - First project - runserver is an invalid syntax

I decided to try developing on python with django, while python is new to me right now.
[I'm using Windows 7 64bit]
Then, i installed python 2.7, added C:\Python27\;C:\Python27\Scripts; to PATH variable.
Next, i installed Eclipse Classic (last version) and installed PyDev, and Django.
I created my first project on Eclipse as a Django project but couldn't run it.
I'm trying (Right click on my project)-> Run as -> PyDev: Django, and i have the following console log:
Validating models...
Traceback (most recent call last): File "C:\Users\Matan\workspace\FirstSample\manage.py", line 10, in <module>
execute_from_command_line(sys.argv) File "C:\Python27\Lib\site-packages\django\core\management\__init__.py", line 443, in execute_from_command_line
utility.execute() File "C:\Python27\Lib\site-packages\django\core\management\__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Python27\Lib\site-packages\django\core\management\base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__) File "C:\Python27\Lib\site-packages\django\core\management\base.py", line 232, in execute
output = self.handle(*args, **options) File "C:\Python27\Lib\site-packages\django\core\management\commands\runserver.py", line 69, in handle
self.run(*args, **options) File "C:\Python27\Lib\site-packages\django\core\management\commands\runserver.py", line 80, in run
and the list goes on...
So i tried to run the project with the python console, using:
import Django
manage.py runserver
and i have the following syntax error:
File "<stdin>", line 1
manage.py runserver
^ SyntaxError: invalid syntax
What is the problem with running my project ? How can i solve this?
Thanks.
Edit:
After trying to run the project with the following command:
python manage.py runserver on the project directory, i receive the following traceback log: Validating models...
Unhandled exception in thread started by <bound method Command.inner_run of <dja ngo.contrib.staticfiles.management.commands.runserver.Command object at 0x000000 0002688748>> Traceback (most recent call last): File "C:\Python27\lib\site-packages\django\core\management\commands\runserver. py", line 91, in inner_run
self.validate(display_num_errors=True) File "C:\Python27\lib\site-packages\django\core\management\base.py", line 266, in validate
num_errors = get_validation_errors(s, app) File "C:\Python27\lib\site-packages\django\core\management\validation.py", lin e 23, in get_validation_errors
from django.db import models, connection File "C:\Python27\lib\site-packages\django\db\__init__.py", line 40, in <modul e>
backend = load_backend(connection.settings_dict['ENGINE']) File "C:\Python27\lib\site-packages\django\db\__init__.py", line 34, in
__geta ttr__
return getattr(connections[DEFAULT_DB_ALIAS], item) File "C:\Python27\lib\site-packages\django\db\utils.py", line 92, in
__getitem
__
backend = load_backend(db['ENGINE']) File "C:\Python27\lib\site-packages\django\db\utils.py", line 24, in load_back end
return import_module('.base', backend_name) File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in im port_module
__import__(name) File "C:\Python27\lib\site-packages\django\db\backends\mysql\base.py", line 16 , in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No mo dule named MySQLdb
Download the pre-compiled python-mysql package for Windows, install it, then run the command again.
While you are there, you might as well also install setuptools if you haven't already.
Error loading MySQLdb module: No mo dule named MySQLdb
You have configured your settings to you MySQL but you have not installed MySQL-python:
pip install MySQL-python
You must be in the project directory to run the python manage.py runserver command. You also need to (1) set the PYTHONPATH environment variable to include your project directory's parent and (2) set the DJANGO_SETTINGS_MODULE environment variable to yourproject.settings
If you've done it correctly, you should be able to go to an unrelated directory (i.e. not your project directory) and do the following import in a python shell:
c:\temp> python
...
>>> from django.conf import settings
the settings module that is imported should then be the one in your project directory...

Categories

Resources