This article will discuss about how to solve a certain error. That error available by executing a certain command. That command is actually just to run a Django-based web application. Actually before executing the command, there is an additional line configuration added to the settings.py file configuration. The following is the location of that file :
C:\python\project\apps>tree . Folder PATH listing for volume Windows Volume serial number is E003-3593 C:\PYTHON\PROJECT\APPS ├───project │ └───__pycache__ | __init__.py | asgi.py | models.py | settings.py | urls.py | wsgi.py └───apps ├───migrations │ └───__pycache__ ├───templates └───__pycache__ C:\python\project\apps>
In the ‘settings.py’, the additional line is exist as follows :
INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'apps', 'crispy_forms', ]
The additional line is ‘crispy_forms’ in the last line of INSTALLED_APPS parameter. By adding and also saving the new added configuration line, the execution process begin. After executing the command for starting the Django-based application, there an error appear as follows :
(myenv) C:\python\project\apps>python manage.py runserver Watching for file changes with StatReloader Exception in thread django-main-thread: Traceback (most recent call last): File "C:\Python38\lib\threading.py", line 932, in _bootstrap_inner self.run() File "C:\Python38\lib\threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "C:\python\myenv\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper fn(*args, **kwargs) File "C:\python\myenv\lib\site-packages\django\core\management\commands\runserver.py", line 110, in inner_run autoreload.raise_last_exception() File "C:\python\myenv\lib\site-packages\django\utils\autoreload.py", line 76, in raise_last_exception raise _exception[1] File "C:\python\myenv\lib\site-packages\django\core\management\__init__.py", line 357, in execute autoreload.check_errors(django.setup)() File "C:\python\myenv\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper fn(*args, **kwargs) File "C:\python\myenv\lib\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\python\myenv\lib\site-packages\django\apps\registry.py", line 91, in populate app_config = AppConfig.create(entry) File "C:\python\myenv\lib\site-packages\django\apps\config.py", line 90, in create module = import_module(entry) File "C:\Python38\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 973, in _find_and_load_unlocked ModuleNotFoundError: No module named 'crispy_forms' Traceback (most recent call last): File "manage.py", line 21, in main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "C:\python\myenv\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line utility.execute() File "C:\python\myenv\lib\site-packages\django\core\management\__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\python\myenv\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv self.execute(*args, **cmd_options) File "C:\python\myenv\lib\site-packages\django\core\management\commands\runserver.py", line 61, in execute super().execute(*args, **options) File "C:\python\myenv\lib\site-packages\django\core\management\base.py", line 371, in execute output = self.handle(*args, **options) File "C:\python\myenv\lib\site-packages\django\core\management\commands\runserver.py", line 96, in handle self.run(**options) File "C:\python\myenv\lib\site-packages\django\core\management\commands\runserver.py", line 103, in run autoreload.run_with_reloader(self.inner_run, **options) File "C:\python\myenv\lib\site-packages\django\utils\autoreload.py", line 618, in run_with_reloader start_django(reloader, main_func, *args, **kwargs) File "C:\python\myenv\lib\site-packages\django\utils\autoreload.py", line 603, in start_django reloader.run(django_main_thread) File "C:\python\myenv\lib\site-packages\django\utils\autoreload.py", line 318, in run self.run_loop() File "C:\python\myenv\lib\site-packages\django\utils\autoreload.py", line 324, in run_loop next(ticker) File "C:\python\myenv\lib\site-packages\django\utils\autoreload.py", line 364, in tick for filepath, mtime in self.snapshot_files(): File "C:\python\myenv\lib\site-packages\django\utils\autoreload.py", line 380, in snapshot_files for file in self.watched_files(): File "C:\python\myenv\lib\site-packages\django\utils\autoreload.py", line 278, in watched_files yield from iter_all_python_module_files() File "C:\python\myenv\lib\site-packages\django\utils\autoreload.py", line 105, in iter_all_python_module_files return iter_modules_and_files(modules, frozenset(_error_files)) File "C:\python\myenv\lib\site-packages\django\utils\autoreload.py", line 141, in iter_modules_and_files resolved_path = path.resolve(strict=True).absolute() File "C:\Python38\lib\pathlib.py", line 1172, in resolve s = self._flavour.resolve(self, strict=strict) File "C:\Python38\lib\pathlib.py", line 200, in resolve return self._ext_to_normal(_getfinalpathname(s)) OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: ''
Tracing back the error message, there is one specific error message that is becoming the main hint to solve the problem. That error is ‘ModuleNotFoundError: No module named ‘crispy_forms”. So, in order to solve the problem, just install the module with the name containing ‘crispy_forms’. Before installing the module, just search the module first to be able to find the exact name of the module. Just execute the following command :
(myenv) C:\python\project\apps>pip search crispy crispy-models (0.1.13) - Shared code for CRISPy web service crispy-tailwind (0.2.0) - A tailwind package for Django Crispy Forms crispy-bootstrap5 (0.1) - Bootstrap5 template pack for django-crispy-forms crispy-templates (0.2.0) - A collection of useful templates for customizing crispy forms layouts. django-crispy-views (1.0.1) - crispy views for django. django-crispy-admin (0.0.6) - Django Crispy Admin allows you to edit your forms with the handy crispy forms, and bootstrap3 FTW! crispy-semantic-ui (1.0.2) - Semantic UI template pack for crispy forms crispy (0.7.3) - Core-Level Spectroscopy Simulations in Python crispy-forms-materialize (0.2) - Django application to add 'django-crispy-forms' layout objects for Materialize crispy-forms-bulma (1.1.4) - Django application to add 'django-crispy-forms' layout objects for Bulma.io django-crispy-bulma (0.2) - Django application to add 'django-crispy-forms' layout objects for Bulma.io crispy-forms-propeller (0.0.2a13) - Django application to add 'django-crispy-forms' layout objects for 'Propeller.in' crispy-forms-foundation (0.8.0) - Django application to add 'django-crispy-forms' layout objects for 'Foundation for sites' crispy-forms-semantic-ui (0.2.0) - Semantic UI templates for django-crispy-forms. crispy-forms-foundation-demo (0.5.0) - Django application to demonstrate 'crispy-forms-foundation' crispy-forms-gds (0.2.1) - Django application to add 'django-crispy-forms' layout objects for the GOV.UK Design System. crispy-forms-bulma-django2 (1.1.5) - Django application to add 'django-crispy-forms' layout objects for Bulma.io django-crispy-contact-form (0.3.8) - Customizable contact form based on crispy-forms with captcha support for Django 1.11+ astro-crispy (0.1.0) - Computational Ridge Identification with SCMS for Python django-crispy (1.8.1) - Best way to have Django DRY forms django-crispy-forms (1.10.0) - Best way to have Django DRY forms crispy-forms-uikit (0.2.0) - django-crispy-bootstrap (0.1.1.1) - UNKNOWN django-crispy-forms-ng (2.0.0) - Best way to have Django DRY forms of the next generation. django-crispy-forms-fancy-formsets (0.1) - UNKNOWN django_crispy_forms_registration (0.1.3) - Library that merges Django auth, registration, and crispy cf-pretty-form-errors (1.0.4) - Make your crispy form errors more pretty django-form-models (0.2.0) - Sample models for modelling django forms and fields, and integrate with crispy forms layout. django-slds-crispyforms (0.1.0) - Django Crispy Forms template overrides for rendering forms using the Salesforce Lightning Design System (myenv) C:\python\apps\apps>
As in the above command execution for searching the module that has the exact name for solving the problem, there is one module name that is suitable. That module name is in the following line :
django-crispy-forms (1.10.0) - Best way to have Django DRY forms
So, in order to solve the problem, just install the module with the name of ‘django-crispy-forms’ as follows :
(myenv) C:\python\project\apps>pip install django-crispy-forms Collecting django-crispy-forms Downloading django_crispy_forms-1.10.0-py3-none-any.whl (107 kB) |████████████████████████████████| 107 kB 2.2 MB/s Installing collected packages: django-crispy-forms Successfully installed django-crispy-forms-1.10.0 WARNING: You are using pip version 20.2.3; however, version 20.3.1 is available. You should consider upgrading via the 'c:\python\myenv\scripts\python.exe -m pip install --upgrade pip' command. (myenv) C:\python\project\apps>
The above module installation is actually a success, if there is no other problem the application execution should just run normally. Just re-execute the previous command for running the Django-based web application as follows :
C:\python\project\apps\admin.py changed, reloading. Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). December 12, 2020 - 14:52:49 Django version 3.1.4, using settings 'apps.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK.
Which python verison are you using i am using python3.9.7 but also i am getting same error please help me
Check this article How to Use Crispy Form Tag in Django by Using a Form