[No module named 'google.appengine' appengine local development error - google-app-engine

I am migrating from python27 to python37. I have ported the python2 code to python3 code. The problem is when i try to run the development server, it says ModuleNotFoundError: No module named 'google.appengine'. I have the google cloud sdk downloaded.
I also have the following google libaries downloaded:
google==2.03; google-api-core==1.17.0; google-auth==1.14.3; google-cloud==0.34.0; google-cloud-core==1.3.0; google-cloud-datastore==1.120; google-cloud-ndb==1.2.0; google-cloud-storage==1.28.0;
I am using the CLOUD_DATASTORE. Does this have anything to do with that? Do i have to migrate?
Here is the full error:
INFO 2020-05-12 15:58:51,741 instance_factory.py:261] Running /tmp/tmpAvEFgc/bin/pip install -r /tmp/tmpjm7s5D
INFO 2020-05-12 15:59:02,605 dispatcher.py:267] Starting module "default" running at: http://192.168.1.15:8080
INFO 2020-05-12 15:59:02,613 instance_factory.py:121] Detected Python 3.7.5
INFO 2020-05-12 15:59:03,607 instance.py:561] Cannot decide GOOGLE_CLOUD_PROJECT, using "test" as a fake value
[2020-05-12 11:59:03 -0400] [30089] [INFO] Starting gunicorn 20.0.4
[2020-05-12 11:59:03 -0400] [30089] [INFO] Listening at: http://0.0.0.0:21217 (30089)
[2020-05-12 11:59:03 -0400] [30089] [INFO] Using worker: sync
[2020-05-12 11:59:03 -0400] [30092] [INFO] Booting worker with pid: 30092
[2020-05-12 11:59:03 -0400] [30092] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/tmp/tmpAvEFgc/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/tmp/tmpAvEFgc/lib/python3.7/site-packages/gunicorn/workers/base.py", line 119, in init_process
self.load_wsgi()
File "/tmp/tmpAvEFgc/lib/python3.7/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
self.wsgi = self.app.wsgi()
File "/tmp/tmpAvEFgc/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/tmp/tmpAvEFgc/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
return self.load_wsgiapp()
File "/tmp/tmpAvEFgc/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
return util.import_app(self.app_uri)
File "/tmp/tmpAvEFgc/lib/python3.7/site-packages/gunicorn/util.py", line 358, in import_app
mod = importlib.import_module(module)
File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/vicktree/Documents/project-noah-3/noah-app/main.py", line 19, in <module>
from handlers.noah_handler import NoahHandler
File "/home/vicktree/Documents/project-noah-3/noah-app/handlers/noah_handler.py", line 16, in <module>
from google.appengine.ext import db
ModuleNotFoundError: No module named 'google.appengine'

The google.appengine module is baked into the first-generation Python (2.7) runtime. It's not available to install via pip, in the second-generation (3.7) runtime, or in any Docker environment.
The only way to use it is by writing and deploying a first-generation App Engine app.
Depending on what you're doing, you should be able to replace it with a client library call instead.
See https://cloud.google.com/appengine/docs/standard/python/migrate-to-python3 for more details.

Related

ImportError: cannot import name 'urlresolvers' from 'django.core'

Can anybody help figuring out the issue and solution.Here is the error for python 3.10.6 and django 3.2.17
python manage.py runserver 0.0.0.0:8001
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/usr/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/home/mindmatrix/Documents/demo/lib/python3.10/site- packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/home/mindmatrix/Documents/demo/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "/home/mindmatrix/Documents/demo/lib/python3.10/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "/home/mindmatrix/Documents/demo/lib/python3.10/site-packages/django/core/management/__init__.py", line 375, in execute
autoreload.check_errors(django.setup)()
File "/home/mindmatrix/Documents/demo/lib/python3.10/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/home/mindmatrix/Documents/demo/lib/python3.10/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/mindmatrix/Documents/demo/lib/python3.10/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/home/mindmatrix/Documents/demo/lib/python3.10/site-packages/django/apps/config.py", line 301, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/mindmatrix/Documents/job_portal_updated_Feb_10/peeldb/models.py", line 8, in <module>
from oauth2client.contrib.django_util.models import CredentialsField
File "/home/mindmatrix/Documents/demo/lib/python3.10/site-packages/oauth2client/contrib/django_util/__init__.py", line 233, in <module>
from django.core import urlresolvers
ImportError: cannot import name 'urlresolvers' from 'django.core' (/home/mindmatrix/Documents/demo/lib/python3.10/site-packages/django/core/__init__.py)
I am trying for version upgrade of the open source project. I have upgraded all the neccessary requirements for the project. Now while running the command python manage.py runserver I am facing this issue.If any one can help?? I`

Having trouble with pyodbc on django

I am working on django project. And testing Sql Server database.
I am using korean linux hosting service gabia. So I don't have any root access.
Even this hosting company blocked yum and rpm.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: libodbc.so.2: cannot open shared object file: No such file or directory
I am keep having this kind of trouble when I import pyodbc. But I can fully use pymssql module.
I have no idea what is wrong with this linux...
This is when I connect django to mssql database with mssql-django package.
Traceback (most recent call last):
File "/web/.local/lib/python3.9/site-packages/mssql/base.py", line 16, in <module>
import pyodbc as Database
ImportError: libodbc.so.2: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/web/.local/lib/python3.9/site-packages/django/core/handlers/wsgi.py", line 130, in __call__
signals.request_started.send(sender=self.__class__, environ=environ)
File "/web/.local/lib/python3.9/site-packages/django/dispatch/dispatcher.py", line 176, in send
return [
File "/web/.local/lib/python3.9/site-packages/django/dispatch/dispatcher.py", line 177, in <listcomp>
(receiver, receiver(signal=self, sender=sender, **named))
File "/web/.local/lib/python3.9/site-packages/django/db/__init__.py", line 46, in reset_queries
for conn in connections.all():
File "/web/.local/lib/python3.9/site-packages/django/utils/connection.py", line 76, in all
return [self[alias] for alias in self]
File "/web/.local/lib/python3.9/site-packages/django/utils/connection.py", line 76, in <listcomp>
return [self[alias] for alias in self]
File "/web/.local/lib/python3.9/site-packages/django/utils/connection.py", line 62, in __getitem__
conn = self.create_connection(alias)
File "/web/.local/lib/python3.9/site-packages/django/db/utils.py", line 208, in create_connection
backend = load_backend(db["ENGINE"])
File "/web/.local/lib/python3.9/site-packages/django/db/utils.py", line 113, in load_backend
return import_module("%s.base" % backend_name)
File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/web/.local/lib/python3.9/site-packages/mssql/base.py", line 18, in <module>
raise ImproperlyConfigured("Error loading pyodbc module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading pyodbc module: libodbc.so.2: cannot open shared object file: No such file or directory
This linux is CentOS 7
I've tried to install unixODBC on /web/.local directory which I can access into. And I successfully executed unixodbc alone, but not with python pyodbc.
I failed to install FreeTDS because I cannot find any way to install FreeTDS on this linux with tar file.
I wonder if I can change the installation path written on pyodbc package file. If I can, then I can fix this problem with changing the installation root of unixODBC to my accessable directory.

ModuleNotFoundError: No module named 'google.cloud.location'

We have an application that uses firestore. It is running on Python 3.x on standard Google app engine. The application was running fine, till this morning when we tried to run the new version. The deployment of the new version is executed without any error. The requirement.txt is as follows -
firebase_admin==3.0.0
sendgrid==6.9.3
google-auth==1.35.0
google-auth-httplib2==0.1.0
jinja2==3.0.3
MarkupSafe==2.0.1
pytz==2021.3
Flask==2.0.2
twilio==6.46.0
httplib2==0.20.2
requests==2.24.0
requests_toolbelt==0.9.1
google-cloud-tasks==2.7.1
google-cloud-logging==1.15.1
googleapis-common-protos==1.54.0
protobuf==3.20.1
We get the following error.
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore_v1/services/firestore/client.py", line 55, in <module>
from google.cloud.location import locations_pb2 # type: ignore
ModuleNotFoundError: No module named 'google.cloud.location'
Please help.
Updated (9-24-2022) with the complete error output.
Traceback (most recent call last):
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
worker.init_process()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/workers/gthread.py", line 92, in init_process
super().init_process()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/workers/base.py", line 134, in init_process
self.load_wsgi()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
self.wsgi = self.app.wsgi()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
return self.load_wsgiapp()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
return util.import_app(self.app_uri)
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/util.py", line 359, in import_app
mod = importlib.import_module(module)
File "/opt/python3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/srv/main.py", line 8, in <module>
from controllers import server, common, header
File "/srv/controllers/server.py", line 19, in <module>
from controllers import basehandler
File "/srv/controllers/basehandler.py", line 12, in <module>
from google.cloud import firestore
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore/__init__.py", line 18, in <module>
from google.cloud.firestore_v1 import __version__
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore_v1/__init__.py", line 36, in <module>
from google.cloud.firestore_v1.async_client import AsyncClient
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore_v1/async_client.py", line 45, in <module>
from google.cloud.firestore_v1.async_transaction import AsyncTransaction
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore_v1/async_transaction.py", line 49, in <module>
from google.cloud.firestore_v1.client import Client
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore_v1/client.py", line 44, in <module>
from google.cloud.firestore_v1.services.firestore import client as firestore_client
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore_v1/services/firestore/__init__.py", line 16, in <module>
from .client import FirestoreClient
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore_v1/services/firestore/client.py", line 55, in <module>
from google.cloud.location import locations_pb2 # type: ignore
ModuleNotFoundError: No module named 'google.cloud.location'
It looks like Google made a mistake in setting requirements for one its Python packages.
If you create a new virtual environment, install with pip install -r you should be able to recreate the error you are seeing in production.
To fix it, I would do pip list on your local machine (in the environment that is still working) and add fixed versions of other installed google packages until it works.
You can test by creating a new Python virtual environment, installing with pip install -r and seeing if it works.
It is a tedious process unfortunately.
I got this exact same error just now while trying to link a Python script to Firestore. I don't know if this is a "correct" solution but I got my code to run and save data to my Firestore database after this doing this.
In the error message, this line specifies the file where google.cloud.location is being imported:
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/google/cloud/firestore_v1/services/firestore/client.py", line 55, in <module>
If you open the client.py file and comment out the line 55 ("from google.cloud.location import locations_pb2 # type: ignore"), then run your code again, the next error message will show the other file where google.cloud.location is being imported. Repeat this process for all five files where this module is imported. (client.py, base.py, grpc.py, grpc_asyncio.py, async_client.py)
From searching through the code, I'm seeing that locations_pb2 (imported from google.cloud.location) is never used. I suspect that commenting this out entirely won't affect the functionality of firebase_admin.

OSX dev_appserver.py file not accessible: '/System/Library/CoreServices/SystemVersion.plist'

I did a gcloud components update 2 days ago and started getting this error when i run dev_appserver.py
(venv) myusername#mymachine:~/projects/myproject$ dev_appserver.py ./ --host 0.0.0.0 --port 8002 --enable_console --env_var GCS_TOKEN=ya29........YJDQAnp772B0
INFO 2019-03-13 23:45:31,205 devappserver2.py:278] Skipping SDK update check.
INFO 2019-03-13 23:45:31,268 api_server.py:275] Starting API server at: http://localhost:64587
INFO 2019-03-13 23:45:31,319 dispatcher.py:256] Starting module "default" running at: http://0.0.0.0:8002
INFO 2019-03-13 23:45:31,325 admin_server.py:150] Starting admin server at: http://localhost:8000
/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/mtime_file_watcher.py:182: UserWarning: There are too many files in your application for changes in all of them to be monitored. You may have to restart the development server to see some changes to your files.
'There are too many files in your application for '
INFO 2019-03-13 23:45:35,237 instance.py:294] Instance PID: 29760
appengine_config
requests.__version__ 2.21.0
Appengine config done
4
ERROR 2019-03-13 23:45:35,986 wsgi.py:263]
Traceback (most recent call last):
File "/usr/local/Caskroom/google-cloud-sdk/latest/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/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/Users/myusername/projects/myproject/main.py", line 34, in <module>
from bp_includes.lib.error_handler import handle_error
File "/Users/myusername/projects/myproject/bp_includes/lib/error_handler.py", line 15, in <module>
from bp_includes.lib import jinja_bootstrap
File "/Users/myusername/projects/myproject/bp_includes/lib/jinja_bootstrap.py", line 7, in <module>
from src.handlers.utils import ordinal
File "/Users/myusername/projects/myproject/src/handlers/utils.py", line 14, in <module>
from lib.pytz.gae import pytz
File "/Users/myusername/projects/myproject/lib/pytz/__init__.py", line 29, in <module>
from pkg_resources import resource_stream
File "/Users/myusername/projects/myproject/lib/pkg_resources/__init__.py", line 1022, in <module>
class Environment(object):
File "/Users/myusername/projects/myproject/lib/pkg_resources/__init__.py", line 1025, in Environment
def __init__(self, search_path=None, platform=get_supported_platform(),
File "/Users/myusername/projects/myproject/lib/pkg_resources/__init__.py", line 263, in get_supported_platform
plat = get_build_platform()
File "/Users/myusername/projects/myproject/lib/pkg_resources/__init__.py", line 472, in get_build_platform
INFO 2019-03-13 23:45:36,002 module.py:861] default: "GET /_ah/warmup HTTP/1.1" 500 -
version = _macosx_vers()
File "/Users/myusername/projects/myproject/lib/pkg_resources/__init__.py", line 439, in _macosx_vers
version = platform.mac_ver()[0]
File "/Users/myusername/projects/myproject/venv/lib/python2.7/platform.py", line 764, in mac_ver
info = _mac_ver_xml()
File "/Users/myusername/projects/myproject/venv/lib/python2.7/platform.py", line 741, in _mac_ver_xml
pl = plistlib.readPlist(fn)
File "/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 75, in readPlist
pathOrFile = open(pathOrFile)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/runtime/stubs.py", line 284, in __init__
raise IOError(errno.EACCES, 'file not accessible', filename)
IOError: [Errno 13] file not accessible: '/System/Library/CoreServices/SystemVersion.plist'
I originally installed gcloud with brew cask install google-cloud-sdk in case that's relevant
It looks like the problem was introduced in gcloud 238.0.0 probably with gcloud app Python Extensions 1.9.84. You can downgrade gcloud to lower version with:
gcloud components update --version 237.0.0
I got it to work by doing the following in appengine_config.py, but I'm hoping that someone has a better solution
try:
from google.appengine.tools.devappserver2.python.runtime.stubs import FakeFile
FakeFile._allowed_dirs.update(['/System/Library/CoreServices/'])
except ImportError:
pass
you can delete the lib folder where you requirements are installed and reinstall it worked for me
pip install -t "lib" -r requirements.txt

Installation of Django Debug Toolbar: TypeError: __init__() takes 1 positional argument but 2 were given

Django 1.10
django-debug-toolbar==1.5
I am working on a new project (I've just installed Django). Trying to install Django Debug Toolbar.
Documentation: https://django-debug-toolbar.readthedocs.io/en/stable/installation.html#prerequisites
According to the documentation, this release of the django-debug-toolbar is compatible with Django 1.10.
What have I done wrong?
settings.py
# { django-debug-toolbar
DEBUG_TOOLBAR_PATCH_SETTINGS = False
INTERNAL_IPS = ['127.0.0.1', ]
if DEBUG:
MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware',]
INSTALLED_APPS += ['debug_toolbar',]
# } django-debug-toolbar
urls.py
from django.conf import settings
from django.conf.urls import include
if settings.DEBUG:
import debug_toolbar
urlpatterns += [
url(r'^__debug__/', include(debug_toolbar.urls)),
]
Traceback
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f97d6ab9840>
Traceback (most recent call last):
File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 142, in inner_run
handler = self.get_handler(*args, **options)
File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/runserver.py", line 27, in get_handler
handler = super(Command, self).get_handler(*args, **options)
File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 64, in get_handler
return get_internal_wsgi_application()
File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/core/servers/basehttp.py", line 49, in get_internal_wsgi_application
return import_string(app_path)
File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/utils/module_loading.py", line 20, in import_string
module = import_module(module_path)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/michael/workspace/photoarchive/photoarchive/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
return WSGIHandler()
File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 153, in __init__
self.load_middleware()
File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/core/handlers/base.py", line 82, in load_middleware
mw_instance = middleware(handler)
TypeError: __init__() takes 1 positional argument but 2 were given
Django 1.10 introduced new style of middleware:
https://docs.djangoproject.com/en/1.10/releases/1.10/#new-style-middleware
There was a bug in django-debug-toolbar related to that change. The bug is now fixed in version 1.6 or later, so just use the latest version released to PyPI.
If you must use versions of django-debug-toolbar older than 1.6 with Django 1.10 or later, you can change MIDDLEWARE to MIDDLEWARE_CLASSES in the Django settings.
I changed MIDDLEWARE to MIDDLEWARE_CLASSES in settings.py.
It's work for me!
Already fixed. There is no need to rename MIDDLEWARE. Just install directly from git:
pip install https://github.com/jazzband/django-debug-toolbar/archive/master.zip
And instead of stable use the latest docs:
http://django-debug-toolbar.readthedocs.io/en/latest/

Resources