[Solved]-Django error cannot import name 'RemovedInDjango30Warning'

2👍

Comment out the following line:

from django.utils.deprecation import RemovedInDjango30Warning

in the files below:

python3.6/site-packages/django/contrib/admin/templatetags/admin_static.py
python3.6/site-packages/django/contrib/staticfiles/templatetags/staticfiles.py

11👍

This is caused by conflicts in Django versions as seen here.

ImportError: cannot import name ‘RemovedInDjango30Warning’

Try uninstalling django

sudo pip uninstall django

and reinstall with a version lower than 3.0

sudo pip install django==2.2

Edit

If you wish to use different versions of Django you can use virtual environments.

First create a requirements.txt example from here

You can generate your project’s requirements by running the pip freeze
command that lists all packages that are installed in your local
machine with their versions.

pip freeze > requirements.txt

Do note that this process can lead to certain unnecessary packages
being written to the requirements file which are installed in your
local machine but not required for the project. You must manually edit
the requirements file in that case.

Then create your virtual environment

Step 1 install virtualenv

pip install virtualenv

Step 2 create virtual enviroment

virtualenv env

Step 3 Activate your environment

env\Scripts\activate

When you wish to deacitvate

deactivate

Step 4 Edit your requirements.txt to have the packages you’ll need for your project.

Step 5 install requirements.txt (in same dir)

pip install -r requirements.txt

Form infomation on deployment with mod_wsgi and Apache try here

2👍

This appears to be from a corrupt Django installation in site-packages. Remove Django and install it again.

For me, I was upgrading an existing project from Django 2.2.6 to 3.1.7. It appears that somehow files from 2.2.6 were still hanging around. I had to run pip uninstall django twice to get back to a clean slate and then pip install django to install the latest version.

1👍

This is caused by django versions. You probably upgraded it.

If you do not want to go back to version 2, create a virtual environment and do pip install django==2.2

👤Not Me

0👍

this error depends on python,pip and django versions.This error comes on mostly running latest django version on python2.

install python3 version

use commands like

pip3 install django

python3 manage.py runserver

0👍

I encountered the same problem.
this problem occur due to 2 version of python or django.
So, if you are running your project through virtual enviornment(venv), please check the python version in it.
By going in the following directly:

myproject/venv/lib/pythonx.y

please ensure that x.y is that version of python whichyou are using in your project.
Or if you are not running your project through venv, please check the python version your project is using and running on.

python --version

0👍

I use django 4.1.4 and python 3.8.

pip3 uninstall django
rm ~/.local/lib/python3.8/site-packages/django/ -r
pip3 install django

0👍

I had two different versions of the Django framework in my virtual environment (versions 2.2 & 3.2) . I had to run twice:

pip3 uninstall django

Then i reinstalled the framework:

pip3 install django

-1👍

i just wanna to say that when you have uninstalled django for some reasons, and when you install it once again you will may appear the problem,just add ‘class RemovedInDjango30warning:pass’ in django/utils/deprecation.py that’s it.

👤joey

Leave a comment