ImportError: cannot import name RemovedInDjango19Warning after Django upgrade - django

I was using Django 1.8 and I wanted to upgrade to the latest version (1.11.6). When I did that I got this error message when trying to run the development server:
from django.utils.deprecation import RemovedInDjango19Warning
ImportError: cannot import name RemovedInDjango19Warning
I can uninstall django and run pip install django=1.9 but I want to keep the latest version. Any tip of how to solve that? Thanks!
PS: I'm running python 2.7.13

The problem was actually in python 2.7.
Reinstalling Python 2.7 solved the issue.
How did I came up with the solution?
I tried python3 manage.py runserver instead of python manage.py runserver and the server worked (but with problems of course since I was using print x instead of print(x) So I knew there was something up with python not django.

Related

ImportError: No module named 'django' despite having it installed running apache2 server

I know that many have posted similar question however I tried most solution without success.
I'm trying to host a webpage with apache2 and django in python3.
In the error log I found ImportError: No module named 'django' when accessing the wsgi.pyfile, where I also added import sys, sys.version to confirm which python version is used and from the error log I can see that I'm running following python version 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609].
When I run python3.5 I see that I uses the same python version and here I can run import django without any error!
EDIT: I checked django.__file__and saw that it was located in /home/USERNAME/.local/lib/python3.5/site-packages/django/init.py and that path /home/USERNAME/.local/lib/python3.5/site-packages wasn't in the sys.path that tried to run django. But adding it with sys.path.append(path) didn't help :(
Any thoughts what I might have messed up?
If you have Setup the whole configuration in VirtualEnv then , i suggest you to activate it by,
source /location to /env/bin activate
pip3 install django=version_id
or pip install django=version id
if you want to pass version id then its good or it will install the latest django from your repo.
Now test Django Version there.
Hope you will no get the error.
Location - means the path where env will be located in project directory, if you have followed the standard installation process of django or else you don't need, and version id- vesion of django framework.
I finally understood how to solve it! first I had to run pip3 uninstall django then run sudo pip3 install django.

import django ModuleNotFoundError: No module named 'django' after install python 2

I have 3 django projects (version 1.11.15), and all errors after I accidentally install Python 2 (I installed the react native), before I used python 3.6.5 via Anaconda.
Some of my project files appear error symbols. And when I try to run "manage.py runserver", it can't run, and an error appears. I uninstalled Python 2, and reinstalled my Anaconda (Python 3.6.5), but it didn't work.
In my opinion there is a problem in the path, but I don't know what that is. I've been looking for a solution, but nothing works. Anyone has a solution? ... thanks
my python version
this is my python path, I don't know what to add here, I just followed a few tutorials that I found
this is my path
This is my requirement.txt
enter image description here
i found it,
it's " python manage.py runserver " not " manage.py runserver "
I have ran into this problem and I found the easiest solution was to write out requirements.txt and remove any unwanted libraries. Then delete the virtualenv and recreate a new with the new requirements.

Running django in virtualenv - ImportError: No module named django.core.management?

I have installed Django after activating my virtualenv but still I am getting following error
from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
If you already activated your virtualenv (source /path/bin/activate) then check if you have installed Django.
pip install django
With next command you can see if Django was installed.
pip freeze | grep django
Another thing that you can try is to remove first line (#!/usr/bin/env python) in the manage.py file.
You should check if django is installed
Activate your environment, then run the following command to see which version is installed :
python -c "import django; print(django.get_version())"
I am using virtual environment so I added this line in manage.py:
sys.path.append('./myvenv/lib/python3.5/site-packages')
in which myvenv is the name of my virtual environment and version of my installed Python is 3.5.
This solved my issued.
I found that I had Python 3.4 and 2.7 installed concurrently, and the pip install django==1.7 command automagically decided the Python 3.4 /dist-packages was where it should live. I CD'd over to the Python 2.7 directory and re-piped it... and all is well.
sudo pip install django --upgrade
worked for me, i am not having virutal environment by the way.
I had the same problem when I was running Django from inside a virtual environment and then using another terminal window ran the command
python manage.py shell without first switching to the venv.
The problem was resolved after I switched back.
I found that I could import the django module from the python interpreter, but django-admin.py could not import it when run from the command line.
I confirmed that I was using the python interpreter in my virtual environment.
I was using a 64-bit version of python. Uninstalling, and installing the 32-bit version, then re-creating my venv solved this for me.
If you're using virtualenv, you can add it to your path using sys.path.append('./myvenv/lib/python3.5/site-packages').
Try closing and opening the terminal again. That worked for me too.

Setting mod_wsgi, django python version

I'm having trouble setting up the correct python version for mod_wsgi / django setup.
After numerous bugs I think i'm nearing the end of this tedious setup... I'm trying to run a command from my manage.py file using ./manage.py collectstatic
This is failing because it's trying to use the Python 2.4 version (I have 2.7 installed as well), I believe the version error only occurs when i manually try and run manage. My django.wsgi file inserts the python 2.7 dir into sys.path
Thanks for your help
python2.7 manage.py collectstatic worked. Thanks to Display Name for the comment

virtualenv using wrong django

I have a virtualenv all set up with the --no-site-packages flag on.
When I did pip install django==1.3 everything seemed to install just fine.
When I ran python manage.py sycndb I get the error.
ImportError django.contrib.staticfiles: No module named staticfiles
I know this is a feature of 1.3 and should work. When I go in to the python shell and type
>>> import django
>>> django.VERSION
(1, 2, 1, 'alpha', 0)
Any idea why I get back 1.2 I have the vitrualenv on and know I am in it because I can import other things I have installed. Everything but django seems to work. It seems I am getting a ghost verson or another version installed on my machine, but that shouldnt happen beacause of the --no-site-packages, right?
Can you perform the following checks:
Are you using python from your virtualenv?
which python
/home/raisins/.virtualenvs/yourenv/bin/python
Open a python shell and check where your django is coming from:
python
>>> import django
>>> django.__path__
>>> ['/home/raisins/.virtualenvs/yourenv/lib/python2.6/site-packages/django']
When you run your pip install command, have you activated your virtual environment?