Stumped right off the bat with GAE Python - python

I'm trying to learn Python and figured I'd build an app to host on GAE because it's free.
I'm following this guide here: http://code.google.com/appengine/docs/python/gettingstartedpython27/helloworld.html
and have the exact files: helloworld.py and app.yaml inside my helloworld directory but when I launch it I get this error:
Traceback (most recent call last):
File "C:\Program Files\Google\google_appengine\google\appengine\runtime\wsgi.py", line 187, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "C:\Program Files\Google\google_appengine\google\appengine\runtime\wsgi.py", line 225, in _LoadHandler
handler = __import__(path[0])
ImportError: No module named helloworld
INFO 2012-03-21 19:36:47,219 dev_appserver.py:2865] "GET / HTTP/1.1" 500 -
Python is still greek to me and it's no fun struggling with environment configuration when you're new to something. What did I do wrong? Does it matter than I have GAE/J installed?

Related

wfastcgi fails import cx_Oracle, but `python -c "import cx_Oracle" succeeds

I have IIS setup with fastCGI, serving a flask app. So far so good. Next I whish to add some database connectivity, so I add the line import cx_Oracle to my app. Now this error is thrown:
Error occurred while reading WSGI handler:
Traceback (most recent call last):
File "D:\Anaconda2\lib\site-packages\wfastcgi.py", line 791, in main
env, handler = read_wsgi_handler(response.physical_path)
File "D:\Anaconda2\lib\site-packages\wfastcgi.py", line 633, in read_wsgi_handler
handler = get_wsgi_handler(os.getenv("WSGI_HANDLER"))
File "D:\Anaconda2\lib\site-packages\wfastcgi.py", line 616, in get_wsgi_handler
raise ValueError('"%s" could not be imported%s' % (handler_name, last_tb))
ValueError: "Bloomberg_server.app" could not be imported:
Traceback (most recent call last):
File "D:\Anaconda2\lib\site-packages\wfastcgi.py", line 600, in get_wsgi_handler
handler = __import__(module_name, fromlist=[name_list[0][0]])
File "D:\website\init__.py", line 6, in import cx_Oracle
ImportError: DLL load failed: The specified module could not be found. StdOut: StdErr:
As the title suggests I fail to reproduce the issue in a controlled environment. The very same import statement works fine in the conda environment and moreover, I can run the Flask debug server just fine with pages that rely on a database connection.
I am at loss. Who has a clue what's going on here? The path/oracle_home variables are pointing to the instant client and I have only one python environment installed.
I am too embarrased to admit how long this has taken me, but I've found the answer.
FastCGI's core business is keeping subprocesses alive so that subsequent calls to the server do not require booting a Python environment. In other words, after installing a python package it is advised to reboot. I solved my first question on SO by rebooting..
The answer to this question got me thinking in the right direction.

How to get a Google App Engine running locally

I'm trying to get a Python Google App Engine to run locally (macOS Sierra) and am having all sorts of trouble with and was wondering what I could possibly be missing. Please note this is my first foray into Python (usually develop with Ruby).
I've downloaded Google App Engine sdk for python and followed the steps to get it up and running. After a few attempts I've placed it within the same directory as my App.
I'm using Python 2.7.x which is what the App requires.
I'm using virtualenv so I've initiated it like so: source bin/activate and try to run the app like so: dev_appserver.py --storage_path=../GAE-storage/ --port=9080 --log_level=info $* .
When I try ti visit the page I get an error like:
Traceback (most recent call last):
File "/Users/wm/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 "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 354, in __getattr__
self._update_configs()
File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 290, in _update_configs
self._registry.initialize()
File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 165, in initialize
import_func(self._modname)
File "/Library/WebServer/Documents/python/flow.city/appengine_config.py", line 19, in <module>
from django.conf import settings
ImportError: No module named django.conf
INFO 2016-11-20 11:09:47,599 module.py:788] default: "GET / HTTP/1.1" 500 -
So, to fix this issue I've downloaded Django manually and extracted it to app directory. Then it complained I don't features, so I've also downloaded it manually and added to the project directory. Now is complaining about something else:
ERROR 2016-11-20 11:29:18,635 wsgi.py:263]
Traceback (most recent call last):
File "/Users/wm/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 "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 354, in __getattr__
self._update_configs()
File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 290, in _update_configs
self._registry.initialize()
File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 165, in initialize
import_func(self._modname)
File "/Library/WebServer/Documents/python/flow.city/appengine_config.py", line 22, in <module>
import features
File "/Library/WebServer/Documents/python/flow.city/flowcity/features.py", line 23, in <module>
from base.basics import get_config
File "/Library/WebServer/Documents/python/flow.city/flowcity/base/basics.py", line 13, in <module>
from dbutils import date_to_str, rescale, get_app_url
File "/Library/WebServer/Documents/python/flow.city/flowcity/dbutils.py", line 23, in <module>
from i18n import _
File "/Library/WebServer/Documents/python/flow.city/flowcity/i18n.py", line 12, in <module>
from django.utils.translation import *
TypeError: Item in ``from list'' not a string
INFO 2016-11-20 11:29:18,641 module.py:788] default: "GET / HTTP/1.1" 500 -
So it makes me wonder if the approach I've taken is the right approach to get the App running locally? When cloning a new project in Ruby, I'd do a bundle install so it'd download all requirements for that project. Is there something similar in Python that I should do?
Please note that I've also tried without virtualenv and results were the same.

Can't find module when generating discovery docs for google app engine in python

I am trying to generate Google App Engine discovery docs for iOS and it's giving me the following error:
Traceback (most recent call last):
File "/usr/local/google_appengine/endpointscfg.py", line 133, in <module>
run_file(__file__, globals())
File "/usr/local/google_appengine/endpointscfg.py", line 129, in run_file
execfile(_PATHS.script_file(script_name), globals_)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 561, in <module>
main(sys.argv)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 557, in main
args.callback(args)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 443, in _GenDiscoveryDocCallback
application_path=args.application)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 302, in _GenDiscoveryDoc
application_path=application_path)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 187, in GenApiConfig
module = __import__(module_name, fromlist=base_service_class_name)
ImportError: No module named default
I am running the following command
/usr/local/google_appengine/endpointscfg.py get_discovery_doc --format roc
default.rock
Also, the following is my app.yaml file. So I am trying to generate the discovery docs for my default module. Also, I have a cloud endpoint api called RockApi in a file called rock.py so what should be my ServiceClass. Like above I have default.rock. Is this correct?
application: rocky-1191
version: pre-alpha-002
runtime: python27
api_version: 1
threadsafe: yes
The 'module' refers to the Python module your class resides in, not the App Engine module. See the official docs for examples.

Azure Flask Application getting ERROR

We are trying to deploy a Python flask application on Azure but keep on reciving 500 error with following trace .
StdErr:
2014-09-22 19:24:07.347000: Unhandled exception in wfastcgi.py: Traceback (most recent call last):
File "D:\Python27\Scripts\wfastcgi.py", line 710, in main
env, handler = read_wsgi_handler(response.physical_path)
File "D:\Python27\Scripts\wfastcgi.py", line 567, in read_wsgi_handler
return env, get_wsgi_handler(handler_name)
File "D:\Python27\Scripts\wfastcgi.py", line 550, in get_wsgi_handler
raise ValueError('"%s" could not be imported' % handler_name)
ValueError: "cpmapp.app" could not be imported
2014-09-22 19:24:07.370000: wfastcgi.py 2.1.0 closed
Can anyone help ?
I've had similar issues understanding why my apps were failing on Azure.
I'm assuming you're using Azure Web Apps?
You must configure your deployment using 2 important files (web.config & deploy.cmd) and adding a requirements.txt file with the list of dependencies.
I have a blog post breaking it down
This post helped me understand what Azure is doing.

Django Book Ch. 3: "No Module named mysite.wsgi"

I've been stuck on this problem for what seems like forever, and none of the other threads I've found seem to help.
When I run python manage.py runserver in cmd, I get this output:
C:\Documents and Settings\ltiokhin\My Documents\DJCode\mysite>python manage.py runserver
Validating models...
0 errors found
Django version 1.4.3, using settings 'settings'
Development server is running at http:___________________________
Quit the server with CTRL-BREAK.
Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x010689 F0>>
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.
py", line 109, in inner_run
handler = self.get_handler(*args, **options)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\management\commands\runserver.py", line 24, in get_handler
handler = super(Command, self).get_handler(*args, **options)
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 39, in get_handler
return get_internal_wsgi_application()
File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 58, in get_internal_wsgi_application
"could not import module '%s': %s" % (app_path, module_name, e)) django.core.exceptions.ImproperlyConfigured: WSGI application 'mysite.wsgi.appli cation' could not be loaded; could not import module 'mysite.wsgi': No module na med mysite.wsgi
Thanks in advance for the help.
Do you use the same version as in the book?
Last time I had this kind of error it was because of that!
Or did you add wsgi to the installed_apps in settings.py?
Look for "wsgi.py" under the folder "C:\Documents and Settings\ltiokhin\My Documents\DJCode\mysite\mysite". Its possible that the standard django application file is missing or its named as something else.

Categories