4


I can import crispy_forms but when I run python3 manage.py runserver
it say no module named crispy_forms, I can not why it is, because when I pip3 list, I can see django-crispy-forms.
so I attach my setup for interpreter, really need your help
interpreter setup image

and Error message in terminal

 >>> python3 manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/Users/eunwoo/anaconda3/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/Users/eunwoo/anaconda3/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/eunwoo/anaconda3/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "/Users/eunwoo/anaconda3/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/Users/eunwoo/anaconda3/lib/python3.7/site-packages/django/utils/autoreload.py", line 77, in raise_last_exception
    raise _exception[1]
  File "/Users/eunwoo/anaconda3/lib/python3.7/site-packages/django/core/management/__init__.py", line 337, in execute
    autoreload.check_errors(django.setup)()
  File "/Users/eunwoo/anaconda3/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "/Users/eunwoo/anaconda3/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/eunwoo/anaconda3/lib/python3.7/site-packages/django/apps/registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "/Users/eunwoo/anaconda3/lib/python3.7/site-packages/django/apps/config.py", line 90, in create
    module = import_module(entry)
  File "/Users/eunwoo/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 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'crispy_forms'

devstefancho
  • 2,072
  • 4
  • 17
  • 34
  • 3
    you have to add 'crispy_forms', in your installed apps – bmons Jan 12 '20 at 13:08
  • 1
    To be more precise to the reply of @bmons, you have to add `"crispy_forms"` in `INSTALLED_APPS` list in your `settings.py`. – Eray Erdin Jan 12 '20 at 21:59
  • Thanks for you guys reply, I found that I needed to restart PyCharm due to changing project interpreter setting.. After restarting that now it works. – devstefancho Jan 14 '20 at 12:40

5 Answers5

0

I had the same error. I had to put "crispy_forms" in double-quotes as @erdin-eray said, and then try to re-import with pip install django-crispy-forms. This solved it for me.

It turns out the first time I did a pip install ... I was not in my (env) virtual environment!

pip freeze > requirements.txt:

asgiref==3.3.1
Django==3.1.3
django-crispy-forms==1.10.0
pkg-resources==0.0.0
pytz==2020.4
sqlparse==0.4.1
bc1984adam
  • 173
  • 1
  • 9
0

If you are using pipenv and creating virtual environments for your projects, you might need to be in your virtual environment's shell. Try using

python3 -m pipenv shell

to start a shell of your virtual environment. You can check to make sure that django-crispy-forms are installed by using the

pip list

command. If you see the desired version of django-crispy-forms installed on this list, then try running the server again using the same command you were using initially:

python3 manage.py runserver
kidbilly
  • 670
  • 9
  • 9
0

I have found that my settings.py is very sensitive to the type of quote marks used.

When I consistently use single quote there is no problem.

Or if I consistantly use the double quote there is also no problem.

But when I tried to use both, I got your error with crispy_forms and crispy_bootstrap5 in the INSTALLED_APPS list.

Charles Knell
  • 342
  • 1
  • 7
-1
pip install django-crispy-forms
pppery
  • 3,731
  • 22
  • 33
  • 46
  • 3
    I doubt that this helps, or even works at all. To convince me otherwise please [edit] and add an explanation of how this works and why it is supposed to help. That would also help to fight the misconception that StackOverflow is a platform for finding programmers who do unpaid programming work for non-programmers. – Yunnosch Jun 21 '20 at 16:41
-1

pip install django-crispy-forms not works for this error. You need to use python command instead python3 for run server.