Introduction
There is an error upon executing the internal service of a Django-based application. So, the error itself exist as part of the article’s title which is ModuleNotFoundError: No module named ‘crispy_forms’. Before going on to the detail of the error message, below is the structure of the Django-based project :
(env) C:\programming\python\django>dir Volume in drive C is Windows Volume Serial Number is E003-3593 Directory of C:\programming\python\django 10/16/2021 11:58 PM <DIR> . 10/16/2021 11:58 PM <DIR> .. 10/16/2021 11:57 PM <DIR> env 10/16/2021 11:57 PM <DIR> myproject 0 File(s) 0 bytes 4 Dir(s) 217,369,694,208 bytes free (env) C:\programming\python\django>cd myproject (env) C:\programming\python\django\myproject>dir Volume in drive C is Windows Volume Serial Number is E003-3593 Directory of C:\programming\python\django\myproject 10/16/2021 11:57 PM <DIR> . 10/16/2021 11:57 PM <DIR> .. 10/16/2021 11:57 PM <DIR> .vscode 09/11/2021 10:27 AM 550 base.html 09/05/2021 03:57 PM 0 db.sqlite3 10/16/2021 11:57 PM <DIR> practice 09/05/2021 03:56 PM 687 manage.py 10/16/2021 11:57 PM <DIR> myapp 10/16/2021 11:57 PM <DIR> myproject 10/16/2021 11:57 PM <DIR> sysapp 10/16/2021 11:57 PM <DIR> templates 3 File(s) 1,237 bytes 8 Dir(s) 217,369,227,264 bytes free (env) C:\programming\python\django\myproject>
The following is the actual error message appear as part of the log of the internal service command execution :
(env) C:\programming\python\django\myproject>python manage.py runserver Watching for file changes with StatReloader Exception in thread django-main-thread: Traceback (most recent call last): File "C:\app\python39\lib\threading.py", line 973, in _bootstrap_inner self.run() File "C:\app\python39\lib\threading.py", line 910, in run self._target(*self._args, **self._kwargs) File "C:\app\python39\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "C:\app\python39\lib\site-packages\django\core\management\commands\runserver.py", line 110, in inner_run autoreload.raise_last_exception() File "C:\app\python39\lib\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception raise _exception[1] File "C:\app\python39\lib\site-packages\django\core\management\__init__.py", line 375, in execute autoreload.check_errors(django.setup)() File "C:\app\python39\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "C:\app\python39\lib\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\app\python39\lib\site-packages\django\apps\registry.py", line 91, in populate app_config = AppConfig.create(entry) File "C:\app\python39\lib\site-packages\django\apps\config.py", line 224, in create import_module(entry) File "C:\app\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 984, in _find_and_load_unlocked ModuleNotFoundError: No module named 'crispy_forms' (env) C:\programming\python\django\myproject>
Solution
The solution for the above problem is simple. The information available in the error message is clearly enough pointing out the problem. It is because there is no module with the name of ‘crispy_forms’. So, in order to make sure that there is no module available with the name of ‘crispy_forms’ and solve the problem, just do the following steps :
- First of all, just search the package or the module with the name of ‘crispy_forms’ as in the following command execution :
(env) C:\programming\python\django>pip_search crispy_forms 🐍 https://pypi.org/search/?q=crispy_forms 🐍 ┌───────────────────────────────────────┬────────────────────┬──────────────┬─────────────────────────────────────────┐ │ Package │ Version │ Released │ Description │ ├───────────────────────────────────────┼────────────────────┼──────────────┼─────────────────────────────────────────┤ │ 📂 crispy-forms-materialize 0.2 Jun 5, 2017 Django application to add │ │ │ │'django-crispy-forms' layout objects │ │ │ │ │ for Materialize │ │ 📂 crispy-forms-primer 0.4.3 May 5, 2021 Django application to add │ │ │ │ 'django-crispy-forms' layout objects │ │ │ │ │ for Github Primer │ │ 📂 django-crispy-forms 1.13.0 Sep 25, 2021 Best way to have Django DRY forms │ 📂 crispy-forms-bulma 1.1.4 Nov 8, 2017 Django application to add │ │ │ │ 'django-crispy-forms' layout objects │ │ │ │ │ for Bulma.io │ │ 📂 crispy-forms-uikit 0.2.0 Apr 19, 2020 │ 📂 crispy-forms-gds 0.2.2 Jan 7, 2021 Django application to add │ │ │ │ 'django-crispy-forms' layout objects │ │ │ │ │ for the GOV.UK Design System. │ │ 📂 crispy-forms-foundation 0.8.0 May 20, 2020 Django application to add │ │ │ │ 'django-crispy-forms' layout objects │ │ │ │ │ for 'Foundation for sites' │ │ 📂 crispy-forms-propeller 0.0.2a13 Mar 11, 2020 Django application to add │ │ │ │ 'django-crispy-forms' layout objects │ │ │ │ │ for 'Propeller.in' │ │ 📂 django_crispy_forms_registration 0.1.3 Jun 9, 2014 Library that merges Django auth, │ │ │ │ registration, and crispy │ │ 📂 crispy-forms-semantic-ui 0.2.0 Oct 22, 2016 Semantic UI templates for │ │ │ │ django-crispy-forms. │ │ 📂 crispy-forms-bulma-django2 1.1.5 Jan 29, 2019 Django application to add │ │ │ │ 'django-crispy-forms' layout objects │ │ │ │ │ for Bulma.io │ │ 📂 crispy-forms-foundation-demo 0.5.0 Apr 2, 2015 Django application to demonstrate │ │ │ │ 'crispy-forms-foundation' │ │ 📂 django-crispy-forms-ng 2.0.0 Apr 8, 2015 Best way to have Django DRY forms of │ │ │ │ the next generation. │ │ 📂 crispy 0.7.3 Jun 27, 2019 Core-Level Spectroscopy Simulations in │ │ │ │ Python │ │ 📂 django-crispy-forms-fancy-formsets 0.1 Jul 2, 2012 UNKNOWN │ 📂 forms2 1.1.2 Apr 3, 2015 Extra features for Django Forms │ 📂 crispy-models 0.1.13 Jan 20, 2020 Shared code for CRISPy web service │ 📂 sst-crispy 1.0.0 Jun 21, 2021 A Python package for using data from │ │ │ │ the Swedish 1 m Solar Telescope's CRisp │ │ │ │ │ Imaging SpectroPolarimeter instrument. │ │ 📂 crispy-cookie 0.6.3 Aug 26, 2021 Splunk app boilerplate builder that │ │ │ │ uses a combination of Cookiecutter and │ │ │ │ │ Ksconf layers. │ │ 📂 crispy-bootstrap5 0.6 Sep 28, 2021 Bootstrap5 template pack for │ │ │ │ django-crispy-forms │ │ 📂 crispy-tailwind 0.5.0 Apr 14, 2021 A tailwind package for Django Crispy │ │ │ │ Forms │ │ 📂 astro-crispy 0.1.0 Jan 22, 2020 Computational Ridge Identification with │ │ │ │ SCMS for Python │ │ 📂 crispy-templates 0.2.0 Jan 17, 2017 A collection of useful templates for │ │ │ │ customizing crispy forms layouts. │ │ 📂 sdh.forms 2.3.0 May 6, 2021 Alternative package for rendering forms │ 📂 asymmetricbase.forms 0.1.1-201404241725 Apr 24, 2014 UNKNOWN │ 📂 blitz-forms 1.0.0 Aug 11, 2021 │ 📂 poplar-forms 1.0.6 Jun 3, 2020 Fleeting forms for Orchid Extender │ 📂 genshi-forms 1.0 May 17, 2009 Form generator and validator for Genshi │ 📂 dynamic-forms 0.9 Nov 26, 2014 Django App to create dynamic Surveys │ 📂 forms_extras 0.1.1 Sep 12, 2011 Extra features, fields and widgets for │ │ │ │ Django forms │ │ 📂 djangocms-forms 0.2.5 Dec 29, 2016 The easiest and most flexible Django │ │ │ │ CMS Form builder w/ ReCaptcha v2 │ │ │ │ │ support! │ │ 📂 pulpo-forms 1.1 May 26, 2015 Django App to create dynamic Surveys │ 📂 omero-forms 1.1.0 May 7, 2020 OMERO forms app for enhanced metadata │ │ │ │ input and provenance │ │ 📂 slack-forms 0.3.0 Sep 22, 2021 Django forms icing on the Slack App │ │ │ │ cake │ │ 📂 cms-forms 0.1.2 Nov 10, 2019 CMS plugin for creating and managing │ │ │ │ forms │ │ 📂 semanticui_forms 0.1.5 Sep 2, 2015 Django forms extension for Semantic UI. │ 📂 capybara-forms 0.0.2 Jan 3, 2019 Dynamic Django forms and filters using │ │ │ │ JSON schema │ │ 📂 tornado-forms 0.0.1 Feb 11, 2019 Build HTML forms from any data source │ │ │ │ in Tornado applications │ │ 📂 eea.forms 7.8 Jun 19, 2020 EEA forms - Custom AT widgets and │ │ │ │ fields │ │ 📂 google_forms 0.3 Jul 9, 2016 Flask web proxy for Google forms └───────────────────────────────────────┴────────────────────┴──────────────┴─────────────────────────────────────────┘
As in the above output command execution, there is one package which is suitable for the ‘crispy-forms’ module. That is the package or the module with the name of ‘django-crispy-forms’. So, continue to install the package or module of ‘django-crispy-forms’.
-
Execute the following command to install that package or module :
(env) C:\programming\python\django>pip install django-crispy-forms Collecting django-crispy-forms Downloading django_crispy_forms-1.13.0-py3-none-any.whl (122 kB) |████████████████████████████████| 122 kB 2.2 MB/s Installing collected packages: django-crispy-forms Successfully installed django-crispy-forms-1.13.0 (env) C:\programming\python\django>
-
Check whether the package or the module is available after the installation above by executing the following command :
(env) C:\programming\python\django\myproject>pip list Package Version ---------------------- --------- asgiref 3.4.1 autopep8 1.5.7 beautifulsoup4 4.10.0 bs4 0.0.1 certifi 2021.10.8 charset-normalizer 2.0.6 colorama 0.4.4 commonmark 0.9.1 dj-database-url 0.5.0 Django 3.2.6 django-ckeditor 6.1.0 django-crispy-forms 1.13.0 django-js-asset 1.2.2 docutils 0.17.1 gunicorn 20.1.0 idna 3.2 mysql-client 0.0.1 mysql-connector-python 8.0.26 mysqlclient 2.0.3 Pillow 8.3.2 pip 21.2.4 pip-search 0.0.7 pycodestyle 2.7.0 Pygments 2.10.0 python-decouple 3.4 pytz 2021.1 requests 2.26.0 rich 10.12.0 setuptools 57.4.0 soupsieve 2.2.1 sqlparse 0.4.1 toml 0.10.2 Unipath 1.1 urllib3 1.26.7 whitenoise 5.3.0 (env) C:\programming\python\django\myproject>
There is a package with the name of ‘django-crispy-forms’ in the output of the above command execution. So, the package or module with the name of ‘django-crispy-forms’ exist in this python virtual environment.
-
Last but not least, after confirming the existence of the package or the module, just run the Django-based internal service once more.