Search code examples
pythondjangodjango-crispy-forms

crispy_forms is not working : ModuleNotFoundError: No module named 'crispy_forms'


Steps that I followed

  1. pip install django-crispy-forms
  2. add inside setting.py
INSTALLED_APPS = [
    ...
    'crispy_forms',
    ...
]

and

CRISPY_TEMPLATE_PACK = 'uni_form'

  1. 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'

Solution

  • 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.