Home > Net >  How can I fix a 'ModuleNotFoundError' in django python?
How can I fix a 'ModuleNotFoundError' in django python?

Time:05-08

I am trying to create a Django python API, and when I created the first app 'authentication' with 'python manage.py startapp authentication', I got the following error while running the server:

Mylaptop@DESKT0P-101D6PT MINGW64 -/Desktop/pizza_delivery S python ./pizza/manage.py runserver Watching for file changes with StatReloader Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\threading.py”, line 973, in _bootstrap_inn er
self. run()
File "C:\Program Files\Python39\lib\threading.py”, line 910, in run self._target(*self._args, **self._kwargs)
File ”C:\Users\Mylaptop\Desktop\pizza_delivery\env\lib\site-packages\django\ut ils\autoreload.py”, line 64, in wrapper fn(*args, **kwargs)
File ”C:\Users\Mylaptop\Desktop\pizza_delivery\env\lib\site-packages\django\co re\management\commands\runserver.py", line 125, in inner_run autoreload.raise_last_exception()
File "C:\Users\Mylaptop\Desktop\pizza_delivery\env\lib\site-packages\django\ut ils\autoreload.py", line 87, in raise_last_exception raise _exception[l]
File "C:\Users\Mylaptop\Desktop\pizza_delivery\env\lib\site-packages\django\co
re\management\  init    .py", line 398, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\Mylaptop\Desktop\pizza_delivery\env\lib\site-packages\django\ut ils\autoreload.py", line 64, in wrapper fn(*args, **kwargs)
File "C:\Users\Mylaptop\Desktop\pizza_delivery\env\lib\site-packages\django\    
init    .py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Mylaptop\Desktop\pizza_delivery\env\lib\site-packages\django\ap ps\registry.py", line 91, in populate app_config = AppConfig.create(entry)
File "C:\Users\Mylaptop\Desktop\pizza_delivery\env\lib\site-packages\django\ap ps\config.py", line 213, in create mod = import_module(mod_path)
File "C:\Program Files\Python39\lib\importlib\  init    .py", line 127, in impor
t_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'authentication.apps'

I did add the app name to the 'setting.py' file :

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

'authentication.apps.AuthenticationConfig',
'orders.apps.OrdersConfig',]

I am pretty sure that I need to specify the path, but I don't know how !!! Note that my folder is organized as follows, and the main project is named 'pizza': new folder content I put it in the project folder.

  • Related