ImportError: cannot import name RemovedInDjango19Warning - python

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.

#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.

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

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.

pip install -Ur requirements.txt
Use This Command It Will Work

Related

./runtests (in django) ImportError: cannot import name 'NullTimeKeeper'

The following command was executed in the tests directory inside the development version of django
./runtests.py
Traceback (most recent call last):
File "./runtests.py", line 26, in <module>
from django.test.utils import NullTimeKeeper, TimeKeeper, get_runner
ImportError: cannot import name 'NullTimeKeeper'
I am using python 3.8 and am following the instructions for contributing to django from https://docs.djangoproject.com/en/3.1/intro/contributing/ where I have resolved all errors up to this point. Could someone explain what I would have to do as I already ran
python3.8 -m pip install -r requirements/py3.txt
in my virtual environment that I created using
python3.8 -m venv /path/to/venv
Never mind I found the answer. It is solved by configuring python3 to 3.8 version instead of 3.6 in the following link configuring python and then executing all of this in the virtual environment.

Django: python3 manage.py migrate ModuleNotFoundError: No module named 'django'

i'm a total noob in django so go easy on me..
i tried to run these commands on ubuntu terminal and gave me the same error
python3 manage.py migrate
python manage.py makemigrations MyAppName
python manage.py migrate
python manage.py syncdb --all
error message:
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
) from exc
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
and i was told that i should never edit manage.py
update: i manged to run the project and made some modifications on it.
Django is not installed, use this comamnd to install it:
pip install django
Just do a check of all modules installed using command - pip list
If it does not show django in the list of modules install it using - pip install django
If it shows django in the list then the version of django installed may not be compatible with the version of python you are using. You can try installing a compatible version of django.
Also, you can create a virtual environment and install django inside the environment.

Airflow: ImportError: No module named configparser

Environment: Python 2.7.5 & Centos 7
I have successfully installed airflow using:
pip install apache-airflow
But when I run
airflow initdb,
it says:
Traceback (most recent call last):
File "/usr/bin/airflow", line 21, in <module>
from airflow import configuration
File "/usr/lib/python2.7/site-packages/airflow/__init__.py", line 35, in <module>
from airflow import configuration as conf
File "/usr/lib/python2.7/site-packages/airflow/configuration.py", line 38, in <module>
from backports.configparser import ConfigParser
ImportError: No module named configparser
What am I missing?
The issue is you have installed a wrong package. airflow was renamed to apache-airflow from 1.8.1. The website you used has outdated docs.
Please install using the following command
export AIRFLOW_GPL_UNIDECODE=yes
pip install apache-airflow
This should install 1.10.0 which is the latest stable version and resolve your issues.

How to use Python 3 (3.5) as the default interpreter in my virtual environment?

I ran into problems when I installed Python 3.5 on Mac. I wanted to use Python 3.5 as the interpreter when I ran my Django development server. I got this issue when I tried it (I know I must install a virtualenv, read below):
$ python3 manage.py runserver
Traceback (most recent call last):
File "manage.py", line 7, in <module>
from mezzanine.utils.conf import real_project_name
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/Mezzanine-4.0.1-py3.5.egg/mezzanine/utils/conf.py", line 7, in <module>
from django.conf import global_settings as defaults
ImportError: No module named 'django'
The first was when I tried installing pip packages it installed by default on the Python 2.7 in my virtual environment:
pip install django==1.9rc2
Collecting django==1.9rc2
Downloading Django-1.9rc2-py2.py3-none-any.whl (6.4MB)
100% |████████████████████████████████| 6.4MB 66kB/s
Installing collected packages: django
Successfully installed django-1.9rc2
I use Django so I tried also install a virtual environment for the first time. First I tried it with pip, but that didn't work.
So how do I setup so that my Python3.5 is the default usage when using Python interpreter and in my virtual environment? I can't figure this out or I have done something wrong in my process.
Edit:
Thanks for the answer and comment. I tried with the both solutions and the same error persisted. See output below:
$ virtualenv -p /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 Django/
Running virtualenv with interpreter /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/virtualenv.py", line 14, in <module>
import shutil
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/shutil.py", line 10, in <module>
import fnmatch
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/fnmatch.py", line 15, in <module>
import functools
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/functools.py", line 21, in <module>
from collections import namedtuple
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/collections/__init__.py", line 16, in <module>
from reprlib import recursive_repr as _recursive_repr
File "/Library/Python/2.7/site-packages/reprlib/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
My virtualenv version: 13.1.2
Your error is related to a known virtualenv bug regarding python-future and mixing up the 2.7 and 3.x module paths, the solution is to downgrade virtualenv to a version < 12.04, 12.0.2 is suggested in the link.
Firstly, If you are going to use multiple versions of python,then you must use Virtual Env.Also then Create your virtualenv using the following command so that it uses python 3.5 as default environment :
virtualenv -p python3 envname
and then install django in the virtualenv.after activating your virtualenv

Python Error: No module named django.core.management

First time here!
And first time with Django also!
I read same issue here on StackOverFlow, e.g: Django:No module named django.core.management but without any result
Purpose:
Install a Django app (based on 1.5.1 on windows 8
I have + tested (e.g: pip --version):
Python 2.7
Pip 1.5.6
Virtualenv 1.11.6
I followed the instructions, and when I run:
python manage.py runserver
P.S:
I created my env,
$ virtualenv --distribute myenv
and activate it using:
source myenv/Scripts/activate
I got this error:
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
Any help how to debug the issue?
PPS: Please read the comments bellow!
Regards
You don't have django installed in your virtual environment.
Just do this: pip install django
In your case, to make sure the right one pip is used: env/Scripts/pip install django
Virtual environment is isolated "python + packages folder", so you need to install your packages again, but for this virtual evironment.
It is obvious, because you have exception at 8 line of manage.py, which tries to import special django function to run command-line commands.

Categories

Resources