I'm running google app engine, python 2.7, and importing Django 1.8. After pulling in python-firebase (-e git://github.com/ozgur/python-firebase.git#egg=python-firebase), I get the following error
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])
File "/base/data/home/apps/s~trac-us/1.392706776803493304/main.py", line 25, in <module>
application = django.core.wsgi.get_wsgi_application()
File "/base/data/home/apps/s~trac-us/1.392706776803493304/libs/django/core/wsgi.py", line 14, in get_wsgi_application
django.setup()
File "/base/data/home/apps/s~trac-us/1.392706776803493304/libs/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/base/data/home/apps/s~trac-us/1.392706776803493304/libs/django/apps/registry.py", line 78, in populate
raise RuntimeError("populate() isn't reentrant")
RuntimeError: populate() isn't reentrant
Many of the other solutions have suggested to alter the wsgi.py file, because django gets installed right before deployment in the requirements.txt file.
Ultimately this leads to the server stating: "Error: Server Error
The server encountered an error and could not complete your request.
Please try again in 30 seconds." How can I resolve this?
I was facing the same issue and removing the database configuration for a sqlite database connection fixed this for me. Issue might've been that the sqlite library that django is looking for underneath was not present and thus, removing the sqlite configuration fixed that for me. pff, I was not using sqlite in that project any way.
However, as per a google groups thread I landed on, the error:
raise RuntimeError("populate() isn't reentrant")
RuntimeError: populate() isn't reentrant
is caused when one of the application that you're trying to load leads to an error within, which leads to this. I'll provide a link to the thread here, and although it's different from your problem(you probably solved it already), you might still find it useful:
Link to groups thread
The answer I was talking about
Hope you find it useful.
Related
I'm running django on Elastic Beanstalk and after pushing a new version of the app I'm getting a 500 internal server error.
The logs show this:
apps.populate(settings.INSTALLED_APPS)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/apps/registry.py", line 83, in populate
raise RuntimeError("populate() isn't reentrant")
RuntimeError: populate() isn't reentrant
mod_wsgi (pid=21994): Target WSGI script '/opt/python/current/app/wsgi.py' cannot be loaded as Python module.
mod_wsgi (pid=21994): Exception occurred processing WSGI script '/opt/python/current/app/wsgi.py'.
Traceback (most recent call last):
File "/opt/python/current/app/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
django.setup(set_prefix=False)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
Any advice on debugging this? My attempts to understand it/google it so far have been unsuccessful.
it normally happens when the interpreter failed to load the source(provided you had it running) or (if you are deploying) it points out to a configuration issue mostly related to the number of threads that try to load the same interpreter.
I would suggest you to do a hard restart of the service that runs the app. This will most likely solve it. If the error persists check your wsgi configuration.
I have a problem with django 1.8. The console shows:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/adriann/django/project_varincenti/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 351, in execute_from_command_line
utility.execute()
File "/home/adriann/django/project_varincenti/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 343, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/adriann/django/project_varincenti/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 177, in fetch_command
commands = get_commands()
File "/home/adriann/django/project_varincenti/env/local/lib/python2.7/site-packages/django/utils/lru_cache.py", line 101, in wrapper
result = user_function(*args, **kwds)
File "/home/adriann/django/project_varincenti/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 72, in get_commands
for app_config in reversed(list(apps.get_app_configs())):
File "/home/adriann/django/project_varincenti/env/local/lib/python2.7/site-packages/django/apps/registry.py", line 137, in get_app_configs
self.check_apps_ready()
File "/home/adriann/django/project_varincenti/env/local/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
There are answers elsewhere on Stackoverflow about how this could be actually about app registry, but I believe it is more often just an indicator that something is wrong in the settings and Django didn't handle failure well.
I just had the exact same error by just having a bad logger filename in LOGGING settings -- the directory I was referring to did not exist, so logger initialisation failed.
It looks like you are using a Virtual Environment.
Perhaps you have an app included under INSTALLED_APPS in settings.py, but it isn't installed (e.g. via pip install django-multisite) in your virtual environment.
(I received this same error after starting to use a Virtual Environment.)
I actually had the same error today, which is strange as everything was working properly yesterday and I do not think I have changed anything.
I got the error when trying to start up the dev server. I had recently upgraded this project to 1.8.
The solution for me was: I changed my PYTHONPATH on the startup script (to make sure it also points to the 1.8 version) of the dev server and everything seemed to work perfectly again.
I am new to Django, I mostly work in rails. I just forked a friends project and am trying to get the server up and running. I have installed all requirements and am running into the following error when i try to call runserver
└─(06:50 PM Fri Apr 12)─(22 files, 128b)─> ./runserver
Validating models...
Unhandled exception in thread started by <bound method Command.inner_run of
< django.contrib.staticfiles.management.commands.runserver.Command object at
0x10c252f50>>
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py",
line 92, in inner_run
self.validate(display_num_errors=True)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 280, in
validate
num_errors = get_validation_errors(s, app)
File "/Library/Python/2.7/site-packages/django/core/management/validation.py", line 35,
in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/Library/Python/2.7/site-packages/django/db/models/loading.py", line 166, in
get_app_errors
self._populate()
File "/Library/Python/2.7/site-packages/django/db/models/loading.py", line 72, in
_populate
self.load_app(app_name, True)
File "/Library/Python/2.7/site-packages/django/db/models/loading.py", line 96, in
load_app
models = import_module('.models', app_name)
File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in
import_module
__import__(name)
File "/Users/RobertZyskowski/Applebutter/calendezi/south/models.py", line 2, in <module>
from south.db import DEFAULT_DB_ALIAS
File "/Users/RobertZyskowski/Applebutter/calendezi/south/db/__init__.py", line 78, in
<module>
db = dbs[DEFAULT_DB_ALIAS]
KeyError: 'default'
Any help is appreciated, thanks!
In order for Django to work, you have to provide settings to it. One of the required settings for Django to function normally is DATABASES. It should be provided as a Python dictionary and within that dictionary, Django looks for the default key. More about that here.
The error you are getting means that Django does not have databases provided to it with the key default. There could be multiple reasons for that. One is that your settings file might not actually have the setting defined for various reasons (e.g. security). In that case all you have to provide that settings and the issue should be resolved. For a sample configuration of the setting, please refer to the link to the docs above. The second reason might be that you might have multiple settings files and you are not providing the correct settings file to the runserver. I noticed that you are not using the manage.py runserver command to start the server. If you will try that command, normally you can provide a --settings parameter:
manage.py runserver --settings=dot.notation.path.to.settings
Also if you are new to Django, please read the Django tutorial. It is very good and should get you started very well. The tutorial is here.
I am creating an app on Google App Engine. I am using Django 1.4 and Python 2.7. Everything works fine on localhost. But after deployment it is not running, I keep getting this on admin logs:
2012-12-15 15:02:41.870
/base/python27_runtime/python27_lib/versions/1/lib/cacerts/urlfetch_cacerts.txt missing; without this urlfetch will not be able to validate SSL certificates.
W 2012-12-15 15:02:41.870
No ssl package found. urlfetch will not be able to validate SSL certificates.
E 2012-12-15 15:02:46.086
Traceback (most recent call last):
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 196, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 266, in _LoadHandler
__import__(cumulative_path)
File "/base/data/home/apps/s~cloudwallforever/1.363864476397206865/djangoappengine/main/__init__.py", line 28, in <module>
setup_env()
File "/base/data/home/apps/s~cloudwallforever/1.363864476397206865/djangoappengine/boot.py", line 82, in setup_env
setup_logging()
File "/base/data/home/apps/s~cloudwallforever/1.363864476397206865/djangoappengine/boot.py", line 130, in setup_logging
if not settings.DEBUG:
File "/base/data/home/apps/s~cloudwallforever/1.363864476397206865/django/utils/functional.py", line 276, in __getattr__
self._setup()
File "/base/data/home/apps/s~cloudwallforever/1.363864476397206865/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/base/data/home/apps/s~cloudwallforever/1.363864476397206865/django/conf/__init__.py", line 87, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/base/data/home/apps/s~cloudwallforever/1.363864476397206865/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/base/data/home/apps/s~cloudwallforever/1.363864476397206865/settings.py", line 6, in <module>
import django.db.backends.mysql.base
File "/base/data/home/apps/s~cloudwallforever/1.363864476397206865/django/db/backends/mysql/base.py", line 14, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
Any ideas why it is happening?
The 'Django Support' documentation hints at the solution, but doesn't make it explicit:
Since the standard django.db.backends.mysql backend uses MySQLdb internally, app.yaml must reference MySQLdb in the list of libraries.
Adding the following to app.yaml seems to fix the ImportError:
libraries:
- name: MySQLdb
version: "latest"
Note that MySQLdb is not currently included in the list of available third party libraries. I tried it on a whim and it seems to have fixed the issue for me, YMMV.enter link description here
As the Cloud SQL docs clearly state, you should be using ''google.appengine.ext.django.backends.rdbms' as your database engine setting.
If it's not working after adding the following to your app.yaml:
libraries:
- name: MySQLdb
version: "latest"
...then take the following steps:
Ensure MySQLdb is installed pip install mysql-python on Mac
Ensure the GAE devserver is pointing to your virtualenv/pip'd python 2.7 installation vs. Mac/*nix's default version as pip may not have installed it there. I resolved Can't find module: MySQLdb by updating the GAE devserver to use: /usr/local/bin/python2.7 e.g. in GAE devserver preferences for Python Path
Note: the preferences can be accessed through the application menus:
If you're using Windows: look under File > Preferences...
If you're using Mac, look under GoogleAppengineLauncher > Preferences...
I'm new to python and django but wanted to start following some tutorials. I installed python, then django, and then the pydev plugin for eclipse. I created a new django project and tried running it. In eclipse I set up a run configuration for manage.py with argument runserver and it said "Validating Models" but never said anything else.
I tried running via command line also but got some errors that I didn't see in eclipse:
C:\Users\JP\workspace\mysite\src\mysite>python manage.py runserver
Validating models...
Unhandled exception in thread started by <function inner_run at 0x02851E30>
Traceback (most recent call last):
File "c:\Python27\lib\site-packages\django\core\management\commands\runserver.
py", line 48, in inner_run
self.validate(display_num_errors=True)
File "c:\Python27\lib\site-packages\django\core\management\base.py", line 245,
in validate
num_errors = get_validation_errors(s, app)
File "c:\Python27\lib\site-packages\django\core\management\validation.py", lin
e 22, in get_validation_errors
from django.db import models, connection
File "c:\Python27\lib\site-packages\django\db\__init__.py", line 75, in <modul
e>
connection = connections[DEFAULT_DB_ALIAS]
File "c:\Python27\lib\site-packages\django\db\utils.py", line 91, in __getitem
__
backend = load_backend(db['ENGINE'])
File "c:\Python27\lib\site-packages\django\db\utils.py", line 32, 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 14
, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No mo
dule named MySQLdb
I assume it has something to do with my sql setup, but I'm not sure since it's a blank project and I haven't written any code yet. I'm more concerned with why nothing showed up in eclipse.
I'm just starting myself. Apparently there's a MySQLdb plugin (sorry if that's not the right term) that you need to use in addition to a standard MySQL install. This is so Python can communicate with MySQL.
It sounds like that you need to include the module in Eclipse System PYTHONPATH.
Go to Windows -> Preference -> Pydev -> Interpreter - Python.
After Select your desired python interpreters (if you have a virtual env), include your MySQL egg and all your other dependencies in your library.
It seems you don't have mysql installed. If you're only trying out django, you could use sqlite which ships with python. You can change the db backend in your settings.py file.