settings import error in django using virtualenv - django

I am using ubuntu 12.04.I am using virtualenv and on that I installed all the packages those I required.When I run the project it gives me error but when I run another project it works.
I am using python2.6.8 and django 1.3.1
Traceback (most recent call last):
File "manage.py", line 4, in
import settings # Assumed to be in the same directory.
Any help will be appreciated.
Thanks in advance.

Try to Import settings.py in python shell, there it will give you the exact error. I think you import some other modules in settings.py those giving you ImportError.

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

After installing spyder django is not working

I installed spyder on my ubuntu system From which django is not working. The error it is showing when i ran the server the error showing is is
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'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
import django
ModuleNotFoundError: No module named 'django'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 17, in <module>
"Couldn't import Django. Are you sure it's installed and "
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?
I need both spyder for OpenCV and also Django. can anyone help
It is working after doing
python3 -m pip install django
thank u mr sahil
The error means that the Django is missing from your system, if you have installed the dependencies in your virtualenv you will need to activate that, or you can just do
pip install django --user
If you have a virtualenv do this,
Linux
source path/to/venv/bin/activate
Windows
path/to/venv/bin/activate
First create a virtual environment, using the following command
python3 -m virtualenv venv
If you get an error saying something similar to this, Virtualenv module not found, you will need to install virtualenv using pip by the following command.
pip3 install virtualenv
Then use the aforementioned command to create the virtual environment.
To activate it just use
source venv/bin/activate
This will activate the virtual environment. Now install Django on it.
pip install django
You don't need to specify a pip version (say pip3) because the virtual environment is created in python3 so pip defaults to pip3 itself.
Now finally run your server
python manage.py runserver localhost:8080

Why do I get "ImportError: cannot import name find_spec" when I start a new Django project?

I'm learning Python in tandem with Django. I initially installed Python 3 on my machine (Debian Wheezy), but read about possible conflicts and removed it with some difficulty.
Now I'm using virtualenv and installed python3 within the env and Django using pip. Django and Python seem to have installed correctly:
# python -c "import django; print(django.get_version())"
1.9.1
# python -V
Python 3.2.3`
but when I try to start a new Django project, I get the following:
# django-admin.py startproject mysite
Traceback (most recent call last):
File "/home/rialaado/Projects/webenv/bin/django-admin.py", line 2, in <module>
from django.core import management
File "/home/rialaado/Projects/webenv/lib/python3.2/site-packages/django/core/management/__init__.py", line 10, in <module>
from django.apps import apps
File "/home/rialaado/Projects/webenv/lib/python3.2/site-packages/django/apps/__init__.py", line 1, in <module>
from .config import AppConfig
File "/home/rialaado/Projects/webenv/lib/python3.2/site-packages/django/apps/config.py", line 6, in <module>
from django.utils.module_loading import module_has_submodule
File "/home/rialaado/Projects/webenv/lib/python3.2/site-packages/django/utils/module_loading.py", line 67, in <module>
from importlib.util import find_spec as importlib_find
ImportError: cannot import name find_spec
A quick google turned up no results that would help me.
What should I do?
find_spec isn't available in Python 3.2.3; it was added in Python 3.4.
Try upgrading to 3.4 or later.
The version of Django you're using (v1.9.1) cannot be used with Python 3.2. Hence, #KarthiG and #MUNGAI NJOROGE are correct, and now you know why.
What Python version can I use with Django?
I got the same problem with docker containers.
find_spec is not available when using Docker containers and django 1.9 and python:3.3 dependency.
Adding the line below in your docker image as a dependency works.
FROM python:3.4

Upgrading Django, how to get manage.py

I am looking to upgrade from Django 1.5 to 1.6.
So I have set up a virtualenv, downloaded everything that was in my pip freeze (but changed the Django version).
I tried
python manage.py runserver
but I am getting an error:
Traceback (most recent call last):
File "manage.py", line 2, in <module>
from django.core.management import execute_manager
ImportError: cannot import name execute_manager
A google tells me this is because execute_manager has gone in Django 1.6. But my manage.py file is from a few versions back (1.3 probably).
Is there a preferred way to upgrade the manage.py?
That gets put there when you run startproject. Should I just look in the Django package for an up to date manage.py? Or is there a preferred way to upgrade? Is there anything else that needs copied / changed at the same time?
Have a look at this http://talks.caktusgroup.com/shipit/2013/django16-upgrade-experience/#/ and see the release note https://docs.djangoproject.com/en/dev/releases/1.6/ of django 1.6 where everything is mentioned about the changes. you may need to arrange your manage.py according to the changes made for django 1.6

Can't import Celery modules

I have a weird problem, I successful installed celery, but I can't import its modules:
>>> import celery # OK
>>> import djcelery
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/django_celery-2.5.5-py2.7.egg/djcelery/__init__.py", line 25, in <module>
from celery import current_app as celery # noqa
ImportError: cannot import name current_app
>>> from celery.decorators import task
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named decorators
this error occurs on celery 2.6.0a3 (from github) or 2.5.3 (from pypi) and django-celery 2.5.5. Tried re-installing several times, and even tried in Jython and I got the same error.
I have no clue what it is, can anyone help me out?
honestly, there is a better answer, which I wrote about here.
It's gotta do with a mismatch between your system python (and particularly, with the python standard lib "os") and your precompiled virtualenv python binary.
Deactivating virtualenv, deleting your virtualenv python binary, and then running the virtualenv script on the same virtualenv folder will recompile python for your virtualenv and fix the issue.
well cloned the project (celery) from github, and a python setup.py install resolved. Weird that it couldn't import its modules when installed via pip in my machine (even when /Library/Python/2.7/site-packages/celery/decorators.py task was there).
Hope it helps someone.