问题
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'
回答1:
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
回答2:
pip install django-crispy-forms
来源:https://stackoverflow.com/questions/59704108/modulenotfounderror-no-module-named-crispy-forms