Python 3.6.2安装后Django启动报错:找不到simplesocial模块
Is This Error Impactful?
Absolutely. This error blocks Django from loading your project’s core settings, so you won’t be able to use any Django-specific functionality in the shell—like interacting with models, running management commands, or accessing project configurations. Until resolved, your Python shell won’t recognize your Django project at all.
Common Causes & Fixes
Let’s walk through the most likely scenarios and straightforward fixes:
You’re not using
manage.pyor are in the wrong directory
When you create a Django project namedsimplesocial, it generates a folder structure wheresimplesocialis your project root (containingsettings.py). If you launch the regular Python shell without navigating to the folder where yourmanage.pyfile lives, Django can’t locate the settings module.
Fix: Open your command prompt/terminal, navigate to the parent folder of yoursimplesocialproject directory, and run:python manage.py shellThis command automatically configures Django’s environment to find your project settings, so you won’t hit the error.
You’re using the plain Python shell but haven’t set the settings module
If you prefer using the regular Python shell (instead ofmanage.py), you need to manually tell Django where to find its settings.
Fix:- First, set the environment variable for your settings module:
- On Windows (Command Prompt):
set DJANGO_SETTINGS_MODULE=simplesocial.settings - On Linux/macOS:
export DJANGO_SETTINGS_MODULE=simplesocial.settings
- On Windows (Command Prompt):
- Then, in the Python shell:
import django django.setup()
This will initialize Django with your project’s settings correctly.
- First, set the environment variable for your settings module:
Typos or mismatched project name
Double-check that your project folder is actually namedsimplesocial(note that this is case-sensitive!). If you accidentally named it something else (likesimple_socialwith an underscore), Django won’t find the module.
Fix: Verify your project folder name and update the settings module path to match (e.g., usesimple_social.settingsif that’s your actual project name).
Quick Recap
The core issue is that Django can’t locate your project’s settings module. Using python manage.py shell is the simplest way to avoid this, as it handles all environment setup automatically. If you need the plain shell, just make sure to set the DJANGO_SETTINGS_MODULE variable before initializing Django.
内容的提问来源于stack exchange,提问作者Shri

