No solutions for django.core.management error - django

I know that this question has been asked and asked again, but none of the solutions seem to works for me. I'm using Django 1.9 with Python 2.7 on Windows 8.1. When I try to run the development server from my projects manage.py I get the ImportError: No module named django core.management.
I only have one version of python
I'm not using a virtual environment
C:\Python27 and C:\Python27\Scripts are included in my path
I can import django in python and get the version number
I can import management from django.core in python
my manage.py was created using pydev and begins with "#!/usr/bin/env python" as seems appropriate according to other answers
I have already uninstalled and reinstalled django via pip
It is possible I might have messed something up when trying to change from 32 bit to 64 bit python in order to interface with Matlab.

Start python from shell, the same way you did when the import works:
>>> import os
>>> os.environ['PYTHONPATH']
'/the/python/path'
Copy this path, and in your manage.py add:
sys.path.append('/the/python/path')
from django.core.management import execute_from_command_line

Related

ImportError: No module named pathlib Windows OS and Python version 3.8

Hi im trying to run a venv for my project. Everythin goes well install requirments and creating a my venv. The problem is that when i try to make a manage.py migrate i get this error. Ive looked everywhere and i got python version 3.8 installed. Pathlib is part of the package from python 3.4.
I use Windows and python 3.8 with Django version 3.0.12- My project is based on a cockiecutter and i dont want to update to the latest version om django.
Does anone know what the problem is and how it can be solved?
manage.py migrate
Traceback (most recent call last):
File "E:\Dev\Fooders\fooders\manage.py", line 4, in <module>
from pathlib import Path
ImportError: No module named pathlib
Try:
python manage.py migrate
# or if it does not work
python3 manage.py migrate

ImportError: cannot import name RemovedInDjango19Warning after Django upgrade

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.

Django installation and import with two Pythons

I'm trying to install Django on my computer, but none of the method I followed seems to work. I tried with pip as described on the Django website, I tried with the setup.py file, and when the installation is done with both methods, I can't import Django :
ImportError: No module named 'django'
For information, I have two Python 3.3 on my computer (32 and 64 bits) in case it change something.
Thanks for helping.
T.

django wont work with python3.3.3

Hello I recently installed the django on my Mac OS X 10.9 using the pip install Django.
The installation was successful, now my python3.3.3 is installed in the following directory:
/usr/local/lib/python3.3/site-packages
Inside this directory there is a directory for django so I am assuming that the installation was success on python 3.
The problem arise when I am trying the following procedure:
django-admin.py startproject mysite
The above command creates with success the directory with the files
Then on this command:
python manage.py runserver
or
python3 manage.py runserver
The error is:
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named 'django'
Moreover, I do find a solution but wont work. Was to change the first comment of the file django-admin.py to link the compiler to the correct version of python, which was fine, but the problem is the same.
Any help?
Check out this tutorial on python development on OSX: http://hackercodex.com/guide/python-development-environment-on-mac-osx/
Virtualenv allows you to create sandboxes where you can install different python versions and python libraries without interfering with other virtual environments or with your system python version/libraries.
Your specific problem though, seems to be that Django was not added to your system path, so python doesn't know where to find the django files. It can be risky to add new things to your system path because it could end up conflicting with existing libraries.
If you use virtualenv, each environment will have its own "system" path and the python executable in that environment will know where to find the django files.

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?