I've been looking thoroughly before asking this question but couldn't find the answer on Stack Overflow. ModuleNotFoundError: No module named 'firstappdjango' has a similar error but does not solve my problem.
I've launched default app without problems and got Django screen etc. I am following a tutorial now and I started simple app with some HTML response. I get error called ModuleNotFoundError: No module named 'adamprojectdjango'
when I want to run server.
What I've checked/some info
my app is called adamproject
app installed in settings.py
INSTALLED_APPS = [
'adamproject'
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
directories look as below
/home/none/eclipse-workspace/test5
├── adamproject
│ └── migrations
└── test5
└── __pycache__
app config file:
from django.apps import AppConfig
class MysiteConfig(AppConfig):
name = 'adamproject'
The ModuleNotFoundError: No module named ‘django’ error occurs when we try to import the ‘ Django ‘ module without installing the package or if you have not installed it in the correct environment. We can resolve the issue by installing the Django module by running the pip install Django command.
One common cause of the ModuleNotFoundError: No module named error is simply that the module you're trying to import doesn't exist. This can happen if you've misspelled the module name, or if you're trying to import a module that's not in your Python path.
The first reason of this error is the name of the module is incorrect, so you have to check out the module name that you had imported. For example, let's try to import os module with double s and see what will happen:
Apparently, there is no module with the name of ‘django’. So,check it first by listing all of the available module in the current python environment by typing the following command :
Consider the following:
my_string = 'adamproject' 'django.contrib.admin'
print(my_string)
# prints:
# adamprojectdjango.contrib.admin
You have a missing comma after 'adamproject'. So it is being concatenated to what you intended to be the subsequent list entry. This results in an attempt to load an app from the module adamprojectdjango
which does not exist.
INSTALLED_APPS = [
'adamproject'
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
print(INSTALLED_APPS)
# prints:
# ['adamprojectdjango.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles']
Instead, your list of INSTALLED_APPS
should be declared like this:
INSTALLED_APPS = [
'adamproject',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With