Crispy_forms is not working : ModuleNotFoundError: No module named 'crispy_forms'
Steps that I followed
- pip install django-crispy-forms
- add inside setting.py
INSTALLED_APPS = [
...
'crispy_forms',
...
]
and
CRISPY_TEMPLATE_PACK = 'uni_form'
- press the run icon of pycharm (top right)
I tried to install
pip install -e git+git://github.com/maraujop/django-crispy-forms.git#egg=django-crispy-forms
I tried to make a migration but same error. I tried to install with pipenv install django-crispy-forms.
I don't have the error if I do : "python3 manage.py runserver" but crispy-forms doesn't work
ERROR :
...
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\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 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'crispy_forms'
It looks like you are trying to use the crispy_forms module in your Django project, but you are getting a "ModuleNotFoundError" indicating that the module could not be found.
There are a few possible reasons why this error might occur:
1.You have not installed the django-crispy-forms package. Make sure you have run the pip install django-crispy-forms command to install the package.
2.You have not added 'crispy_forms' to the INSTALLED_APPS list in your Django settings. Make sure you have added 'crispy_forms' to the INSTALLED_APPS list in your settings.py file.
3.You have not specified the CRISPY_TEMPLATE_PACK setting in your Django settings. Make sure you have added the CRISPY_TEMPLATE_PACK setting to your settings.py file, like this: CRISPY_TEMPLATE_PACK = 'uni_form'
4.You are running the Django development server with a different version of Python than the one you used to install the django-crispy-forms package. Make sure you are using the same version of Python to run the development server as the one you used to install the package.
I hope this helps. Let me know if you have any questions or if you need further assistance.
Solution, when you install crispy_form with pip3 install django-crispy-forms
It works and it does the installation well but not in the right place. The installation is done in the Python directory of the computer.
pythonsoftwarefoundation.python.3.10\localcache\local-packages\python310\site-packages
But With PyCharm, I use a venv where I store all the configuration.
It is necessary to retrieve the files installed in the Python directory (in my case crispy_forms) and drag them into the venv/(app name)/lib/site-packages
.