4
votes

Here is my relevant directory structure (Windows 7, Python 2.7, virtualenv)

-userProf
-   -   manage.py
    -   -UserProfile
            -   sampleapp_db
            -   urls.py
            -   views.py
            -   wsgi.py
            -   __init__.py
            -   
            -libs
            -   -   __init__.py
            -   -allauth
            -       -   app_settings.py
            -       -   models.py
            -       -   tests.py
            -       -   urls.py
            -       -   utils.py
            -       -   __init__.py
            -       -   
            -       -account
            -       -   -   admin.py
            -       -   -   context_processors.py
            -       -   -   models.py
            -       -   -   urls.py
            -       -   -   __init__.py
            -       -socialaccount
            -       -   -   admin.py
            -       -   -   context_processors.py
            -       -   -   models.py
            -       -   -   urls.py
            -       -   -   views.py
            -       -   -   __init__.py
            -       -   -   
            -       -templates
            -           -account
            -           -   -   base.html
            -           -   -   email.html
            -settings
            -       base_settings.py
            -       dev.py
            -       __init__.py
            -       
            -static
                -css

I get the following error when I try to run this django app Error: No module named account

I have read other posts on SO that refer to the syspath being the issue or that the appname matches the project name

Django Shell No module named settings

...as a result of this, I added the following statements in the base_settings.py file

import sys
base = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
base_parent = os.path.dirname(base)
sys.path.append(base)
sys.path.append(base_parent)
sys.path.append(os.path.join(base,'libs'))
sys.path.append(os.path.join(base,'libs','allauth','account'))

I verified that the sys.path is correct by putting a break in PyCharm and evaluating sys.path

Should I be putting this in manage.py?

Some other SO postings referred to not being able to import the module but I can launch the python console and import UserProfile.libs.allauth.account without any exceptions being thrown!

My base_setings.py has the following relevant section

INSTALLED_APPS = (
    'UserProfile.libs.allauth.account',
)
1

1 Answers

6
votes

looks like libs/allauth dir is missing the file;

__init__.py

Based on comments the final solution was to update the sys.path file in the manage.py file

Making the changes in the settings.py were not being seeing as it was not able to get to the settings.py file, until changes were made to the manage.py file.