So, I've been following the tutorial steps here https://docs.djangoproject.com/en/1.9/intro/tutorial02/ and I got to the step where I am supposed to run this command:
python manage.py makemigrations polls
When I run it, I get this error:
python manage.py makemigrations polls Traceback (most recent call last): File "<frozen importlib._bootstrap>", line 2218, in_find_and_load_unlocked AttributeError: 'module' object has no attribute '__path__' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/home/tgumm/pythonenv/tutorial/lib/python3.4/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line utility.execute() File "/home/tgumm/pythonenv/tutorial/lib/python3.4/site-packages/django/core/management/__init__.py", line 327, in execute django.setup() File "/home/tgumm/pythonenv/tutorial/lib/python3.4/site-packages/django/__init__.py", line 18, in setup apps.populate(settings.INSTALLED_APPS) File "/home/tgumm/pythonenv/tutorial/lib/python3.4/site-packages/django/apps/registry.py", line 85, in populate app_config = AppConfig.create(entry) File "/home/tgumm/pythonenv/tutorial/lib/python3.4/site-packages/django/apps/config.py", line 116, in create mod = import_module(mod_path) File "/home/tgumm/pythonenv/tutorial/lib/python3.4/importlib/__init__.py", line 109, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 2254, in _gcd_import File "<frozen importlib._bootstrap>", line 2237, in _find_and_load File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 2254, in _gcd_import File "<frozen importlib._bootstrap>", line 2237, in _find_an``d_load File "<frozen importlib._bootstrap>", line 2221, in _find_and_load_unlocked ImportError: No module named 'polls.apps.PollsConfigdjango'; 'polls.apps' is not a package
Here are my models:
from django.db import models # Create your models here. from django.db import models class Question(models.Model): question_text = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') class Choice(models.Model): question = models.ForeignKey(Question, on_delete=models.CASCADE) choice_text = models.CharField(max_length=200) votes = models.IntegerField(default=0)
score:-1
If we are getting error regarding not a package
than most of the time it may happen that we missed to add __init__.py
file within the directory where we are getting this error.
score:0
If none of the above/below fix your problem and you came here with the same errors make sure that you do not have a __init__.py
in your top level directory. Hope this helps someone out there!
Some more answer related to the same question
- No module named 'polls.apps.PollsConfigdjango'; Django project tutorial 2
- Help with "Error: No module named polls" from the Django Project Tutorial 1
- Django 1.9 Tutorial Part 2: No module named 'polls.apps' when running python manage.py makemigrations polls
- Django Tutorial 1 - ImportError: No module named apps
- Running django tutorial tests fail - No module named polls.tests
- Django Import Error: No module named apps
- ImportError: No module named mysql.base, in django project on Ubuntu 11.04 server
- Django reusable apps tutorial, ImportError: No module named 'polls'
- Django - ImportError: No module named apps
- "ImportError: No module named urls" while following Django Tutorial
score:0
you forget to add "," after 'polls.apps.PollsConfig' "," must include a comma "," ... 'polls.apps.PollsConfig',
score:1
If you come from Django Tut here's the problem You just missed a comma after 'polls.apps.PollsConfig'. so it should be
INSTALLED_APPS = [
'polls.apps.PollsConfig',
'django.contrib.admin',
....
]
Related question
- 'ImportError: no module named admin' when trying to follow the Django Girls tutorial
- Import Error: No module named django - for specific project
- "ImportError: No module named cv2" when running Django project from PyCharm IDE
- Problem validating django project no module named 'project name'
- django error - ImportError: No module named apps
- ImportError: No module named simple while running manage.py test in django project
- Running django-admin tutorial erros: no module named django
- django tutorial no module named staticfilespolls error
- ModuleNotFoundError: No module named 'jinja2' during deployment of django project on heroku
- Why does my Django project throw an ImportError: no module named my_project.wsgi?
score:3
I was getting a similar error: ImportError: No module named 'polls'
The cause was that I stored my apps inside the "apps" directory. The solution is to change the code inside apps.py
from:
class PollsConfig(AppConfig):
name = 'polls'
to ("apps" is the name of my django apps directory):
class PollsConfig(AppConfig):
name = 'apps.polls'
score:4
Quoted from https://code.djangoproject.com/ticket/27139
Description
In tutorial 02, Writing your first Django app, part 2, typing in
INSTALLED_APPS = [
'polls.apps.PollsConfig',
....
will cause an ImportError: No module named 'polls.apps.PollsConfig'; 'polls.apps' is not a package
This is resolved by instead putting
INSTALLED_APPS = [
'polls',
....
score:10
Anyone who is getting ModuleNotFoundError: No module named 'pollsdjango'
And INSTALLED_APPS :
INSTALLED_APPS = [
'polls.apps.PollsConfig'
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
Solution:
You forgot to add comma(,) at the end of line 'polls.apps.PollsConfig'
INSTALLED_APPS = [
'polls.apps.PollsConfig', <----this comma
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
score:14
You just missed a comma after 'polls.apps.PollsConfig'
.
Don't worry, it happens for the best of us!
score:31
check for comma "," after 'polls.apps.PollsConfigdjango'
score:36
ImportError: No module named 'polls.apps.PollsConfigdjango'
You forgot to add ',' in the list
score:142
The first problem is this warning in the traceback:
No module named 'polls.apps.PollsConfigdjango'
That means that you are missing a comma after 'polls.apps.PollsConfig
in your INSTALLED_APPS
setting. It should be:
INSTALLED_APPS = (
...
'polls.apps.PollsConfig',
'django....',
...
)
The second problem is the warning 'polls.apps' is not a package
. That suggests that you have installed Django 1.8, but you are following the Django 1.9 tutorial.
If you are using Django 1.8, then follow the 1.8 tutorial so that you don't hit problems like this. Adding the polls app to INSTALLED_APPS
is covered here in the Django 1.8 tutorial. Note that it doesn't use PollsConfig
.
INSTALLED_APPS = (
...
'polls',
)
Credit To: stackoverflow.com
Related Query
- Django Mezzanine ImportError: No module named apps
- "ImportError: No module named dummy" on fresh Django project
- Django ImportError: No Module named apps when running on Openshift
- django import error - No module named core.management
- Django Rest Framework -- no module named rest_framework
- Django - "no module named django.core.management"
- Django import error - no module named django.conf.urls.defaults
- "No module named simple" error in Django
- No module named django but it is installed
- Django -- How to have a project wide templatetags shared among all my apps in that project
More Query from same tag
- Uvicorn async workers are still working synchronously
- Django COUNT with JOIN and GROUP BY SQL query
- How can i save data to text file from django form inputs?
- Django - Get the first attribute from all objects in a Model
- Inline formset factory - pass request to child form
- Django show render_to_response in template
- Regular expression for UK Mobile Number - Python
- Django comments in shell
- Django circular import error between models and signal callback functions
- How can I override how rest-auth saves users?
- Can I install Django as offline in Windows 7?
- Issue with ManyToMany Relationships not updating immediately after save
- If I need a database view or not?
- Django unique_together on primary key
- login with forms doesn't work