ModuleNotFoundError: No module named 'polls'

I am following the tutorial for Django. I am stuck on the last part of the documentation page: resuable_apps.

The package/module I want to use is

/django-polls/ in /mysite/

When I am trying to make the app pluggable by removing it from the project sub-directory to a directory of the same level something goes wrong.

My file hierarchy is as follows:

django-polls mysite

LICENSE			docs		polls
README.rst		setup.cfg


    PKG-INFO		dependency_links.txt
    SOURCES.txt		top_level.txt


    ./django-polls/polls:	migrations
    __pycache__	static
        __init__.cpython-38.pyc	tests.cpython-38.pyc
        admin.cpython-38.pyc	urls.cpython-38.pyc
        apps.cpython-38.pyc	views.cpython-38.pyc

    ./django-polls/polls/migrations:	__pycache__



            images		style.css


db.sqlite3	mysite	templates


        __init__.cpython-38.pyc	urls.cpython-38.pyc
        settings.cpython-38.pyc	wsgi.cpython-38.pyc

    admin	polls


        detail.html	index.html	results.html

When I run ‘python runserver’ in the /mysite/ directory I get back “ModuleNotFoundError: No module named ‘polls’.”

My mysite/ file is:

Django settings for mysite project.

Generated by 'django-admin startproject' using Django 3.1.5.

For more information on this file, see

For the full list of settings and their values, see

from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

# Quick-start development settings - unsuitable for production
# See

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '#lhl+l#0!)tl1f$a2r#_n^la4t%bic4x)=ro0$h0dbd*y@yf@s'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True


# Application definition

#	'polls.apps.PollsConfig',


ROOT_URLCONF = 'mysite.urls'

        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR / 'templates'],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [

WSGI_APPLICATION = 'mysite.wsgi.application'

# Database

    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',

# Password validation

        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',

# Internationalization


TIME_ZONE = 'America/Los_Angeles'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)

STATIC_URL = '/static/'

My is:

from django.apps import AppConfig

class PollsConfig(AppConfig):
    name = 'polls'

If you have finished the documentation tutorial, please let me know how how get past the last part where we move the /polls/ directory into the /django-polls/ directory! Thank you very much.

Unfortunately, the formatting is making it difficult to understand your directory layout. Can you enclose that with the backticks (```) like you’ve done for your code?

I have fixed the formatting. Thank you for your interest and time to help me solve this problem!

So after you’ve moved your project to your other directory, the tutorial goes through the steps of you creating a package and then installing it. After it has been installed, you should see it listed when you do a pip list. Does your package show up?
(It looks to me like you are about at the step for Using your own package)

If you have gone through the installation process but are not seeing the package listed, double and triple check the files you created in Packaging your app. Also make sure that if you’re using a virtual environment for your app, that your virtual environment is active when you install your package, and that you’re checking pip list while that venv is active.

If you’re still having problems, it would be helpful if you posted the contents of the files created in the Packaging your app step - setup.cfg,, and

I have resolved the issue! The problem was

python -m pip install --user django-polls/dist/django-polls-0.1.tar.gz

Which gave me the error:

ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.

Which prompted me to just to do a normal

python -m pip install django-polls/dist/django-polls-0.1.tar.gz

Now everything works as intended!

Thank you very much for the help and guidance. It has been very satisfying after many failed attemps to have it work. I noticed your response on a similar problem to mine on the forum. Thank you again for your contribution to the community. It has been a pleasure learning from you.

1 Like