ImportError: cannot import name RemovedInDjango19Warning
Solution 1
@MaxRah This is caused by conflicts in Django versions. As mentioned by others, you will have to remove pip uninstall django
and reinstall your preferred version: pip install django==1.9
This should resolve the issue.
Solution 2
I was getting this error while trying to use cron-jobs on python (using kronos library)
#getting error while trying to run kronos cron job
python manage.py runtask complain
as @ olivrg metioned this fixed the issue (reinstall django in my case i was using version 1.8.X so i upgraded to 1.9X)
sudo pip uninstall django
sudo pip install django==1.9
Solution 3
Your installation is corrupt, your traceback does not match the code from version 1.8.7 (from importlib import import_module
is on line 8, not line 4). You need to uninstall Django and do a clean install.
I would highly recommend to set up a virtual environment for your Django project, using virtualenv. This is a de facto standard to separate different python environments on your system. The corruption likely occurred because different projects tried to install different versions of Django in your system-wide site packages.
Related videos on Youtube
MaxRah
Updated on June 04, 2022Comments
-
MaxRah almost 2 years
I'm on Django 1.8.7 and I've just installed Django-Allauth by cloning the repo and running pip install in the app's directory in my webapp on the terminal. Now when I run manage.py migrate, I get this error:
➜src git:(master) ✗ python manage.py migrate Traceback (most recent call last): File "manage.py", line 8, in <module> from django.core.management import execute_from_command_line File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 10, in <module> from django.apps import apps File "/Library/Python/2.7/site-packages/django/apps/__init__.py", line 1, in <module> from .config import AppConfig File "/Library/Python/2.7/site-packages/django/apps/config.py", line 6, in <module> from django.utils.module_loading import module_has_submodule File "/Library/Python/2.7/site-packages/django/utils/module_loading.py", line 4, in <module> from importlib import import_module File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 6, in <module> from django.utils.deprecation import RemovedInDjango19Warning ImportError: cannot import name RemovedInDjango19Warning ➜ src git:(master) ✗
I've checked and I'm still on django 1.8.7 so it wasn't accidently upgraded.
-
Chris Hawkes about 8 yearsthat's an interesting error, as far as I can tell no such exception even exists in the Django project, at least my searches of RemovedInDjango19Warning came up empty.
-
knbk about 8 years@ChrisHawkes It exists in Django 1.7 and Django 1.8.
-
-
MaxRah about 8 yearsThanks. I am actually using a virtualenv. I think something happened while I was installing allauth to cause the corruption. Do you have a useful link on how to do a clean django uninstallion?
-
knbk about 8 years@MaxRah Just uninstall, remove the
django
directory in yoursite-packages
if it still exists, and reinstall. -
MaxRah about 8 yearsThanks @knbk reinstalling django fixed it.