Forums

ImportError: No module named crispy_forms

[edited by admin: formatting]

Traceback (most recent call last):

  File "./manage.py", line 10, in <module>execute_from_command_line(sys.argv)

  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()

  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute
    django.setup()

  File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)

  File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)

  File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 94, in create
    module = import_module(entry)

  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)

ImportError: No module named crispy_forms

I have tried everything to get this to work. I have reloaded the web app.

I have also tried installing both inside and outside the virtual environment using the easy install and the pip install and the pip3 install.

Don't really know what to do next. Your help is appreciated.

So judging from the traceback, you would need to "pip2.7 install --user". What happens when you do that install?

Hi i don't know why the traceback is saying that the python version is 2.7.

I ran this....

$ mkvirtualenv --python=/usr/bin/python3.7 mysite-virtualenv

and it said something about depreciated f(l)avor.

However when I checked the interpreter it said the version was 3.7.

Why does it say python 2.7 and how do i fix that?

seems like after you fixed the python version and set up your webapp to use your virtualenv correctly (from the webapp tabs settings), and reloaded your webapp, your website is now working?

Yes but I still cant use manage.py migrate it still comes out with a ImportError: No module named crispy_forms

does this have something to do with the python 2.7?

Hi when trying to create the 3.7 environment this is whats happening


CRHerna@glenn-liveconsole7:~$ mkvirtualenv --python=/usr/bin/python3.7 mysite-virtualenv

Running virtualenv with interpreter /usr/bin/python3.7

Using base prefix '/usr'

/usr/local/lib/python2.7/dist-packages/virtualenv.py:1041: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses

import imp

New python executable in /home/CRHerna/.virtualenvs/mysite-virtualenv/bin/python3.7

Also creating executable in /home/CRHerna/.virtualenvs/mysite-virtualenv/bin/python

Installing setuptools, pip, wheel...


Why is it looking in python2.7?

can you give the exact commands from when you made the virtualenv to when you ran the code? Where is this error traceback that you are seeing? Is it from the webapp error logs? Or from the console? Or from running code from the file editor?

hey did anyone ever find the answer to his problem? i am facing the same issue

did you follow the solutions suggested?

I was able to solve this by going to my pythonanywhere account > Web > scroll down to Code > Python Version.

My python version was 3.8. So i went to bash and ran pip3.8 install django-crispy-forms --user

then I reloaded my website and refreshed my website and it worked.

I'm too stupid to understand how to use the virtual environment part. It kept saying stuff about my python version is 3.7 when it should be 3.8 so I just gave up and deleted my virtual environment.

Hi @alisayt -- how did you create the virtualenv?

.

2021-09-10 12:47:58,955: Error running WSGI application
2021-09-10 12:47:58,955: ModuleNotFoundError: No module named 'crispy_forms'
2021-09-10 12:47:58,955:   File "/var/www/expomart_pythonanywhere_com_wsgi.py", line 20, in <module>
2021-09-10 12:47:58,956:     application = get_wsgi_application()
2021-09-10 12:47:58,956: 
2021-09-10 12:47:58,956:   File "/usr/local/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2021-09-10 12:47:58,956:     django.setup(set_prefix=False)
2021-09-10 12:47:58,956: 
2021-09-10 12:47:58,956:   File "/usr/local/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
2021-09-10 12:47:58,957:     apps.populate(settings.INSTALLED_APPS)
2021-09-10 12:47:58,957: 
2021-09-10 12:47:58,957:   File "/usr/local/lib/python3.7/site-packages/django/apps/registry.py", line 91, in populate
2021-09-10 12:47:58,957:     app_config = AppConfig.create(entry)
2021-09-10 12:47:58,957: 
2021-09-10 12:47:58,957:   File "/usr/local/lib/python3.7/site-packages/django/apps/config.py", line 224, in create

[edit by admin: formatting]

Have you installed the package? This help page explains how to do that.

i am already install pip install django-crispy-forms
but i face again this problem

What is the exact command that you used to install it?

I have the save problem in my pythonanywhere environment.The application work locally.when i deploy i got this error: Error running WSGI application ModuleNotFoundError: No module named 'crispy_forms'

See the help page that giles linked to above.