Facing trouble in running python manage.py runserver - python

I am trying to run python manage.py runserver and till today I never faced any issues. Whenever I run python manage.py runserver I get this-
$ python manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
August 11, 2019 - 05:34:42
Django version 2.1.5, using settings 'try_django.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f0b20e6d6a8>
Traceback (most recent call last):
File "/home/user/anaconda3/lib/python3.7/site-packages/django/utils/module_loading.py", line 13, in import_string
module_path, class_name = dotted_path.rsplit('.', 1)
ValueError: not enough values to unpack (expected 2, got 1)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/user/anaconda3/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 45, in get_internal_wsgi_application
return import_string(app_path)
File "/home/user/anaconda3/lib/python3.7/site-packages/django/utils/module_loading.py", line 17, in import_string
module = import_module(module_path)
File "/home/user/anaconda3/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/user/Dev/try_django_new/src/try_django/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/home/user/anaconda3/lib/python3.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
return WSGIHandler()
File "/home/user/anaconda3/lib/python3.7/site-packages/django/core/handlers/wsgi.py", line 136, in __init__
self.load_middleware()
File "/home/user/anaconda3/lib/python3.7/site-packages/django/core/handlers/base.py", line 34, in load_middleware
middleware = import_string(middleware_path)
File "/home/user/anaconda3/lib/python3.7/site-packages/django/utils/module_loading.py", line 15, in import_string
raise ImportError("%s doesn't look like a module path" % dotted_path) from err
ImportError: blog doesn't look like a module path
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/user/anaconda3/lib/python3.7/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/home/user/anaconda3/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 137, in inner_run
handler = self.get_handler(*args, **options)
File "/home/user/anaconda3/lib/python3.7/site-packages/django/contrib/staticfiles/management/commands/runserver.py", line 27, in get_handler
handler = super().get_handler(*args, **options)
File "/home/user/anaconda3/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 64, in get_handler
return get_internal_wsgi_application()
File "/home/user/anaconda3/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 50, in get_internal_wsgi_application
) from err
django.core.exceptions.ImproperlyConfigured: WSGI application 'try_django.wsgi.application' could not be loaded; Error importing module.
I looked for solutions and found out that in the settings.py file I should change WSGI_APPLICATION = 'application' to WSGI_APPLICATION = 'wsgi.application' but it was already so in my settings.py file.

Based on the error it looks like you have an entry of simply 'blog' in your MIDDLEWARE settings. Django middleware requires a path to a class so 'blog' is not a valid value.
That's based on these lines from your traceback:
middleware = import_string(middleware_path)
File "/home/user/anaconda3/lib/python3.7/site-packages/django/utils/module_loading.py", line 15, in import_string
raise ImportError("%s doesn't look like a module path" % dotted_path) from err
ImportError: blog doesn't look like a module path

Django's server needs to find your application as defined in wsgi.py, so you need to set `WSGI_APPLICATION = '<project-name>.wsgi.application'.
See the docs at https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/
which state:
WSGI servers obtain the path to the application callable from their configuration. Django’s built-in server, namely the runserver command, reads it from the WSGI_APPLICATION setting. By default, it’s set to
<project_name>.wsgi.application, which points to the application callable in <project_name>/wsgi.py.

Related

Django postgres psycopg2: ImproperlyConfigure even though module installed

I am using Django for the first time but have used PostgreSQL previously. I am trying to follow the official Django tutorial to set up with a database. I have followed everything but I get an error when using the command "python manage.py migrate" that psycopg2 is not found even though I have it
installed.Traceback (most recent call last):
File "/Users/alexanderverheecke/Library/Python/3.9/lib/python/site-packages/django/db/backends/postgresql/base.py", line 24, in <module>
import psycopg2 as Database
ModuleNotFoundError: No module named 'psycopg2'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/alexanderverheecke/Documents/GitHub/mysite/manage.py", line 22, in <module>
main()
File "/Users/alexanderverheecke/Documents/GitHub/mysite/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/Users/alexanderverheecke/Library/Python/3.9/lib/python/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/Users/alexanderverheecke/Library/Python/3.9/lib/python/site-packages/django/core/management/__init__.py", line 420, in execute
django.setup()
File "/Users/alexanderverheecke/Library/Python/3.9/lib/python/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/alexanderverheecke/Library/Python/3.9/lib/python/site-packages/django/apps/registry.py", line 116, in populate
app_config.import_models()
File "/Users/alexanderverheecke/Library/Python/3.9/lib/python/site-packages/django/apps/config.py", line 269, in import_models
self.models_module = import_module(models_module_name)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/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 "/Users/alexanderverheecke/Library/Python/3.9/lib/python/site-packages/django/contrib/auth/models.py", line 3, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/Users/alexanderverheecke/Library/Python/3.9/lib/python/site-packages/django/contrib/auth/base_user.py", line 49, in <module>
class AbstractBaseUser(models.Model):
File "/Users/alexanderverheecke/Library/Python/3.9/lib/python/site-packages/django/db/models/base.py", line 141, in __new__
new_class.add_to_class("_meta", Options(meta, app_label))
File "/Users/alexanderverheecke/Library/Python/3.9/lib/python/site-packages/django/db/models/base.py", line 369, in add_to_class
value.contribute_to_class(cls, name)
File "/Users/alexanderverheecke/Library/Python/3.9/lib/python/site-packages/django/db/models/options.py", line 231, in contribute_to_class
self.db_table, connection.ops.max_name_length()
File "/Users/alexanderverheecke/Library/Python/3.9/lib/python/site-packages/django/utils/connection.py", line 15, in __getattr__
return getattr(self._connections[self._alias], item)
File "/Users/alexanderverheecke/Library/Python/3.9/lib/python/site-packages/django/utils/connection.py", line 62, in __getitem__
conn = self.create_connection(alias)
File "/Users/alexanderverheecke/Library/Python/3.9/lib/python/site-packages/django/db/utils.py", line 193, in create_connection
backend = load_backend(db["ENGINE"])
File "/Users/alexanderverheecke/Library/Python/3.9/lib/python/site-packages/django/db/utils.py", line 113, in load_backend
return import_module("%s.base" % backend_name)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/Users/alexanderverheecke/Library/Python/3.9/lib/python/site-packages/django/db/backends/postgresql/base.py", line 28, in <module>
raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named 'psycopg2'
I am using the settings as mentioned in the Django tutorial:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'DatabaseName',
'USER': 'UserName',
'PASSWORD': 'Userpassword',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
I have confirmed that I have the necessary packages installed and in the same location :
pip freeze:
Django==4.1.3
psycopg2==2.9.5
psycopg2-binary==2.9.5
pip show Django/psycopg2/psycopg2-binary:
Django : Location: /opt/homebrew/lib/python3.10/site-packages
Psycopg2: Location: /opt/homebrew/lib/python3.10/site-packages
psycopg2-binary: Location: /opt/homebrew/lib/python3.10/site-packages
It's seems like you use system python for running your migrations. Error traceback contains following path of python binary: "/Users/alexanderverheecke/Library/Python/3.9/...", however in pip show command your python path is "/opt/homebrew/lib/python3.10/".
Actually I don't understand how it's even possible, because first one looks like Windows path and the second one like Linux...
Anyway. Try something of this and run migrate command again:
activate/deactivate virtual environment if you use it
change your OS to the correct one
run pip install again
Make shure command which python(for Linux), gcm python (for Windows) returns the same python path as pip show.

Django CMS: Error while setting up django-cms

I'm having a WSGI error while following the installation set up for django-cms from th official documentation.
I ran test with python manage.py cms check and it was sucessful.
Checking django CMS installation
Sekizai
Sekizai is installed [OK]
Sekizai template context processor is installed [OK]
Sekizai namespaces 'js' and 'css' found in 'home.html' [OK]
Plugin instances
================
Plugin instances of 0 types found in the database [OK]
The plugins in your database are in good order [OK]
Presence of "copy_relations"
All plugins and page/title extensions have "copy_relations" method if needed. [OK]
PlaceholderField
PlaceholderField configuration okay [OK]
OVERALL RESULTS
9 checks successful!
Installation okay
But when I try running server, I get this thread of errors.
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
July 22, 2022 - 08:47:41
Django version 3.2.14, using settings 'projcms.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\adedi\Documents\Dev\Projects\Django\dj-cms\env\lib\site-packages\django\utils\module_loading.py", line 13, in import_string
module_path, class_name = dotted_path.rsplit('.', 1)
ValueError: not enough values to unpack (expected 2, got 1)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\adedi\Documents\Dev\Projects\Django\dj-cms\env\lib\site-packages\django\core\servers\basehttp.py", line 45, in get_internal_wsgi_application
return import_string(app_path)
File "C:\Users\adedi\Documents\Dev\Projects\Django\dj-cms\env\lib\site-packages\django\utils\module_loading.py", line 17, in import_string
module = import_module(module_path)
File "C:\Users\adedi\AppData\Local\Programs\Python\Python310\lib\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 "C:\Users\adedi\Documents\Dev\Projects\Django\dj-cms\projcms\wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "C:\Users\adedi\Documents\Dev\Projects\Django\dj-cms\env\lib\site-packages\django\core\wsgi.py", line 13, in get_wsgi_application
return WSGIHandler()
File "C:\Users\adedi\Documents\Dev\Projects\Django\dj-cms\env\lib\site-packages\django\core\handlers\wsgi.py", line 127, in __init__
self.load_middleware()
File "C:\Users\adedi\Documents\Dev\Projects\Django\dj-cms\env\lib\site-packages\django\core\handlers\base.py", line 40, in load_middleware
middleware = import_string(middleware_path)
File "C:\Users\adedi\Documents\Dev\Projects\Django\dj-cms\env\lib\site-packages\django\utils\module_loading.py", line 15, in import_string
raise ImportError("%s doesn't look like a module path" % dotted_path) from err
ImportError: djangocms_text_ckeditor doesn't look like a module path
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\adedi\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1009, in _bootstrap_inner
self.run()
File "C:\Users\adedi\AppData\Local\Programs\Python\Python310\lib\threading.py", line 946, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\adedi\Documents\Dev\Projects\Django\dj-cms\env\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\adedi\Documents\Dev\Projects\Django\dj-cms\env\lib\site-packages\django\core\management\commands\runserver.py", line 138, in inner_run
handler = self.get_handler(*args, **options)
File "C:\Users\adedi\Documents\Dev\Projects\Django\dj-cms\env\lib\site-packages\django\contrib\staticfiles\management\commands\runserver.py", line 27, in get_handler
handler = super().get_handler(*args, **options)
File "C:\Users\adedi\Documents\Dev\Projects\Django\dj-cms\env\lib\site-packages\django\core\management\commands\runserver.py", line 65, in get_handler
return get_internal_wsgi_application()
File "C:\Users\adedi\Documents\Dev\Projects\Django\dj-cms\env\lib\site-packages\django\core\servers\basehttp.py", line 47, in get_internal_wsgi_application
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: WSGI application 'projcms.wsgi.application' could not be loaded; Error importing module.
I have inspected my code and can't seem to find any answer.

Unable to Run Django-Spirit raise InvalidTemplateLibrary( django.template.library.InvalidTemplateLibrary

I am trying to Run django-spirit and followed the documentation https://spirit.readthedocs.io/en/latest/installation.html
and using version django-spirit 0.12.3
i followed as bellow
Get started
New in Spirit 0.5
Latest version can be installed through pip:
Install Spirit:
pip install django-spirit
Start your site:
spirit startproject mysite
Set up the database:
cd mysite
python manage.py spiritinstall
Create an administrator account:
python manage.py createsuperuser
python manage.py runserver
python manage.py makermigrations
python manage.py migrate
when i push python manage.py runserver command it thorugh the bellow error.
i have checked out the database too and its empy no tables/database is created
i am using python 3.9 and the requirements versions as per the project requirements
struggling since yesterday but no success
PS C:\Users\gsminfinity.com\Desktop\gsminfinity.com\Spirit-master\community> python manage.py runserver
Performing system checks...
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\gsminfinity.com\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\utils.py", line 66, in __getitem__
return self._engines[alias]
KeyError: 'django'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\gsminfinity.com\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\backends\django.py", line 121, in get_package_libraries
module = import_module(entry[1])
File "C:\Users\gsminfinity.com\AppData\Local\Programs\Python\Python39\lib\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 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "C:\Users\gsminfinity.com\AppData\Local\Programs\Python\Python39\lib\site-packages\spirit\core\templatetags\spirit_tags.py", line 3, in <module>
from spirit.comment import tags as comment
File "C:\Users\gsminfinity.com\AppData\Local\Programs\Python\Python39\lib\site-packages\spirit\comment\tags.py", line 11, in <module>
from .forms import CommentForm
ImportError: cannot import name 'CommentForm' from partially initialized module 'spirit.comment.forms' (most likely due to a circular import) (C:\Users\gsminfinity.com\AppData\Local\Programs\Python\Python39\lib\site-packages\spirit\comment\forms.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\gsminfinity.com\AppData\Local\Programs\Python\Python39\lib\threading.py", line 950, in _bootstrap_inner
self.run()
File "C:\Users\gsminfinity.com\AppData\Local\Programs\Python\Python39\lib\threading.py", line 888, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\gsminfinity.com\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\gsminfinity.com\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\commands\runserver.py", line 118, in inner_run
self.check(display_num_errors=True)
File "C:\Users\gsminfinity.com\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\base.py", line 392, in check
all_issues = checks.run_checks(
File "C:\Users\gsminfinity.com\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\checks\registry.py", line 70, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "C:\Users\gsminfinity.com\AppData\Local\Programs\Python\Python39\lib\site-packages\django\contrib\admin\checks.py", line 78, in check_dependencies
for engine in engines.all():
File "C:\Users\gsminfinity.com\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\utils.py", line 90, in all
return [self[alias] for alias in self]
File "C:\Users\gsminfinity.com\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\utils.py", line 90, in <listcomp>
return [self[alias] for alias in self]
File "C:\Users\gsminfinity.com\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\utils.py", line 81, in __getitem__
engine = engine_cls(params)
File "C:\Users\gsminfinity.com\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\backends\django.py", line 25, in __init__
options['libraries'] = self.get_templatetag_libraries(libraries)
File "C:\Users\gsminfinity.com\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\backends\django.py", line 43, in get_templatetag_libraries
libraries = get_installed_libraries()
File "C:\Users\gsminfinity.com\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\backends\django.py", line 108, in get_installed_libraries
for name in get_package_libraries(pkg):
File "C:\Users\gsminfinity.com\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\backends\django.py", line 123, in get_package_libraries
raise InvalidTemplateLibrary(
django.template.library.InvalidTemplateLibrary: Invalid template library specified. ImportError raised when trying to load 'spirit.core.templatetags.spirit_tags': cannot import name 'CommentForm' from partially initialized module 'spirit.comment.forms' (most likely due to a circular import)
(C:\Users\gsminfinity.com\AppData\Local\Programs\Python\Python39\lib\site-packages\spirit\comment\forms.py)

Django Crispy Forms

I am fairly new to Django and I have installed and am trying to use crispy forms in my web app.I have added crispy_forms to my installed apps with a comma after it. When I run the server I get this error:
Watching for file changes with StatReloader
Performing system checks...
Exception in thread Thread-3:
Traceback (most recent call last):
File "c:\users\amart\django\django\template\utils.py", line 66, in __getitem__
return self._engines[alias]
KeyError: 'django'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\amart\django\django\template\backends\django.py", line 121, in get_package_libraries
module = import_module(entry[1])
File "C:\Users\amart\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\amart\AppData\Local\Programs\Python\Python36-32\lib\site-packages\crispy_forms\templatetags\crispy_forms_field.py", line 10, in <module>
from crispy_forms.utils import TEMPLATE_PACK, get_template_pack
File "C:\Users\amart\AppData\Local\Programs\Python\Python36-32\lib\site-packages\crispy_forms\utils.py", line 11, in <module>
from django.utils.lru_cache import lru_cache
ModuleNotFoundError: No module named 'django.utils.lru_cache'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\amart\AppData\Local\Programs\Python\Python36-32\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\Users\amart\AppData\Local\Programs\Python\Python36-32\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "c:\users\amart\django\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "c:\users\amart\django\django\core\management\commands\runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "c:\users\amart\django\django\core\management\base.py", line 390, in check
include_deployment_checks=include_deployment_checks,
File "c:\users\amart\django\django\core\management\base.py", line 377, in _run_checks
return checks.run_checks(**kwargs)
File "c:\users\amart\django\django\core\checks\registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "c:\users\amart\django\django\contrib\admin\checks.py", line 59, in check_dependencies
for engine in engines.all():
File "c:\users\amart\django\django\template\utils.py", line 90, in all
return [self[alias] for alias in self]
File "c:\users\amart\django\django\template\utils.py", line 90, in <listcomp>
return [self[alias] for alias in self]
File "c:\users\amart\django\django\template\utils.py", line 81, in __getitem__
engine = engine_cls(params)
File "c:\users\amart\django\django\template\backends\django.py", line 25, in __init__
options['libraries'] = self.get_templatetag_libraries(libraries)
File "c:\users\amart\django\django\template\backends\django.py", line 43, in get_templatetag_libraries
libraries = get_installed_libraries()
File "c:\users\amart\django\django\template\backends\django.py", line 108, in get_installed_libraries
for name in get_package_libraries(pkg):
File "c:\users\amart\django\django\template\backends\django.py", line 125, in get_package_libraries
"trying to load '%s': %s" % (entry[1], e)
django.template.library.InvalidTemplateLibrary: Invalid template library specified. ImportError raised when trying to load 'crispy_forms.templatetags.crispy_forms_field': No module named 'django.utils.lru_cache'
I don't know what is wrong with my code. I have found some other users who have issues using crispy forms but are getting a different error. They were also unable to import crispy forms from the python shell but that is working for me. Even if I only add crispy forms to my installed apps without trying to apply it in my templates, I still get an error. Please let me know what I'm doing wrong. Thanks in advance.
Your version of django-crispy-forms is outdated, this has been fixed.
Update it by running:
pip install django-crispy-forms -U
-U makes pip upgrade your current installation to the newest.
You can find more about it by running pip install -h
The problem has been solved. I uninstalled the django version I had and used:
pip install Django==2.1.7
Thank you #YugandharChaudhari for helping me realize to change versions.

Django Apache mod_wsgi - Unable to open database file

After upgrading mod_wsgi to the latest version, my app can no longer access its caching db (sqlite).
The Apache error log shows the following:
mod_wsgi (pid=1050): Target WSGI script '/location/to_my_project/project_name/wsgi.py' cannot be loaded as Python module.
mod_wsgi (pid=1050): Exception occurred processing WSGI script '/location/to_my_project/project_name/wsgi.py'.
aceback (most recent call last):
File "/location/to_my_project/project_name/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/location/to/my/env/lib/python3.5/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
return WSGIHandler()
File "/location/to/my/env/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 153, in __init__
self.load_middleware()
File "/location/to/my/env/lib/python3.5/site-packages/django/core/handlers/base.py", line 80, in load_middleware
middleware = import_string(middleware_path)
File "/location/to/my/env/lib/python3.5/site-packages/django/utils/module_loading.py", line 20, in import_string
module = import_module(module_path)
File "/location/to/my/env/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 "/location/to_my_project/project_name/middleware/some_middleware.py", line 16, in <module>
include_get_headers=True,
File "/location/to/my/env/lib/python3.5/site-packages/requests_cache/core.py", line 182, in install_cache
backend = backends.create_backend(backend, cache_name, backend_options)
File "/location/to/my/env/lib/python3.5/site-packages/requests_cache/backends/__init__.py", line 50, in create_backend
return registry[backend_name](cache_name, **options)
File "/location/to/my/env/lib/python3.5/site-packages/requests_cache/backends/sqlite.py", line 28, in __init__
self.responses = DbPickleDict(location + extension, 'responses', fast_save=fast_save)
File "/location/to/my/env/lib/python3.5/site-packages/requests_cache/backends/storage/dbdict.py", line 58, in __init__
with self.connection() as con:
File "/usr/lib/python3.5/contextlib.py", line 59, in __enter__
return next(self.gen)
File "/location/to/my/env/lib/python3.5/site-packages/requests_cache/backends/storage/dbdict.py", line 70, in connection
con = sqlite.connect(self.filename)
sqlite3.OperationalError: unable to open database file
The user running the process, has however created the file after the error has occurred. When logging in with that user, I can also open / edit the file. Other users with the same problem have reported that changing the path to the file from absolute to relative have solved their issue, but mine has been relative all along. the cache is also created in the correct directory.
mod_wsgi version: 4.5.14 (previous version 4.3.0)
Django: 1.10
Apache: 2.4.18
Server: Ubuntu 16.04
I have not changed the python path after upgrading the wsgi module. Any suggestions on what might be wrong?

Categories