Aim: Build projectoxford into raspberrypi3 - https://channel9.msdn.com/Blogs/jsturtevant/Setting-up-Project-Oxford-for-Python-on-Windows
I have reached the steps of:
pi@raspberrypi:~/happy-image-tester-django $ source env/bin/activate
(env) pi@raspberrypi:~/happy-image-tester-django $ python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 16, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named 'django'
After which, I tried to download django module by using
pip install django
However, after downloading django, when I try to run python manage.py runserver, I have unhandled exception. The results are as shown below.
(env) pi@raspberrypi:~/happy-image-tester-django $ python manage.py runserverPerforming system checks...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x75b7ac00>
Traceback (most recent call last):
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 121, in inner_run
self.check(display_num_errors=True)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/core/management/base.py", line 364, in check
include_deployment_checks=include_deployment_checks,
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/core/management/base.py", line 351, in _run_checks
return checks.run_checks(**kwargs)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/core/checks/registry.py", line 73, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/urls/resolvers.py", line 397, in check
for pattern in self.url_patterns:
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/utils/functional.py", line 36, in get
res = instance.__dict__[self.name] = self.func(instance)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/urls/resolvers.py", line 536, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/utils/functional.py", line 36, in get
res = instance.__dict__[self.name] = self.func(instance)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/urls/resolvers.py", line 529, in urlconf_module
return import_module(self.urlconf_name)
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 673, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/pi/happy-image-tester-django/HappyOrMad/urls.py", line 6, in <module>
from django.conf.urls import patterns, url
ImportError: cannot import name 'patterns'
A check online (https://github.com/jgiannuzzi/taiga-contrib-saml-auth/issues/1) told me that url.py is now fix but I have no idea why it doesnt work still. Other online checks shows that patterns have been deprecated after Django version 1.10; I tried to debug according to the results found online but all could not work for me. I have listed out some of the codes I've tried below.
https://stackoverflow.com/questions/38786036/importerror-cannot-import-name-patterns states that I can use from django.conf.urls import include, url
instead of django.conf.urls import patterns, url
; but after editing accordingly, my error results are as follows:
(env) pi@raspberrypi:~/happy-image-tester-django $ python manage.py runserver
Performing system checks...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x75ba7c00>
Traceback (most recent call last):
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 121, in inner_run
self.check(display_num_errors=True)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/core/management/base.py", line 364, in check
include_deployment_checks=include_deployment_checks,
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/core/management/base.py", line 351, in _run_checks
return checks.run_checks(**kwargs)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/core/checks/registry.py", line 73, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/urls/resolvers.py", line 397, in check
for pattern in self.url_patterns:
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/utils/functional.py", line 36, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/urls/resolvers.py", line 536, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/utils/functional.py", line 36, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/urls/resolvers.py", line 529, in urlconf_module
return import_module(self.urlconf_name)
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 669, in exec_module
File "<frozen importlib._bootstrap_external>", line 775, in get_code
File "<frozen importlib._bootstrap_external>", line 735, in source_to_code
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/pi/happy-image-tester-django/HappyOrMad/urls.py", line 9
from django.conf.urls import include
I have also tried changing the url.py as follows by uncommenting the
"from django.conf.urls import include
from django.contrib import admin
admin.autodiscover()"
"""
Definition of urls for HappyOrMad.
"""
from datetime import datetime
from django.conf.urls import pattern, url
# Uncomment the next lines to enable the admin:
from django.conf.urls import include
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
url(r'^$', 'app.views.home', name='home'),
url(r'^upload','app.views.upload', name='upload'),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
# url(r'^admin/', include(admin.site.urls)),
)
The original url.py file is as follows:
"""
Definition of urls for HappyOrMad.
"""
from datetime import datetime
from django.conf.urls import patterns, url
# Uncomment the next lines to enable the admin:
# from django.conf.urls import include
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns('',
# Examples:
url(r'^$', 'app.views.home', name='home'),
url(r'^upload','app.views.upload', name='upload'),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
# url(r'^admin/', include(admin.site.urls)),
)
After editing the url.py with the code provided, the error is as follows:
(env) pi@raspberrypi:~/happy-image-tester-django $ python manage.py runserver
Performing system checks...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x75bfbc00>
Traceback (most recent call last):
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 121, in inner_run
self.check(display_num_errors=True)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/core/management/base.py", line 364, in check
include_deployment_checks=include_deployment_checks,
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/core/management/base.py", line 351, in _run_checks
return checks.run_checks(**kwargs)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/core/checks/registry.py", line 73, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/urls/resolvers.py", line 397, in check
for pattern in self.url_patterns:
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/utils/functional.py", line 36, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/urls/resolvers.py", line 536, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/utils/functional.py", line 36, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/urls/resolvers.py", line 529, in urlconf_module
return import_module(self.urlconf_name)
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 673, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/pi/happy-image-tester-django/HappyOrMad/urls.py", line 11, in <module>
url(r'^$', 'app.views.home', name='home'),
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/conf/urls/__init__.py", line 13, in url
return re_path(regex, view, kwargs, name)
File "/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/urls/conf.py", line 73, in _path
raise TypeError('view must be a callable or a list/tuple in the case of include().')
TypeError: view must be a callable or a list/tuple in the case of include().
Migration error and remove django warning:
(env) pi@raspberrypi:~/happy-image-tester-django $ python manage.py runserverPerforming system checks...
/home/pi/happy-image-tester-django/HappyOrMad/urls.py:13: RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got app.views.home). Pass the callable instead.
url(r'^$', 'app.views.home', name='home'),
/home/pi/happy-image-tester-django/HappyOrMad/urls.py:14: RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got app.views.upload). Pass the callable instead.
url(r'^upload','app.views.upload', name='upload'),
System check identified no issues (0 silenced).
You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.
January 17, 2018 - 10:51:12
Django version 1.9.1, using settings 'HappyOrMad.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
python./home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/template/utils.py:37: RemovedInDjango110Warning: You haven't defined a TEMPLATES setting. You must do so before upgrading to Django 1.10. Otherwise Django will be unable to load templates.
"unable to load templates.", RemovedInDjango110Warning)
/home/pi/happy-image-tester-django/env/lib/python3.5/site-packages/django/shortcuts.py:89: RemovedInDjango110Warning: The context_instance argument of render_to_string is deprecated.
using=using)