ModuleNotFoundError: No module named 'students.urls.py'; 'students.urls' is not a package

Viewed 38

i am just a beginner in python learning from tutorials i can't just run the server, i followed the same steps mentioned in that tutorial but its showing me this error, i searched for some possible answers on stack overflow but couldn't find any answer that could resolve my issue, hopeless what to do with this,

my directory structure is as enter image description here

in python console in pycharm its showing me this error

Error:Cannot run program "C:\Users\Dell\PycharmProjects\webProject\venv\Scripts\python.exe" (in directory "C:\Users\Dell\Desktop\mydjangoproject"): CreateProcess error=2, The system cannot find the file specified

in pycharm terminal its showing me this error

>  res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\django\urls\resolvers.py", line 715, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\functional.py", line 57, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\django\urls\resolvers.py", line 708, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\Dell\Desktop\mydjangoproject\mydjangoproject\urls.py", line 7, in <module>
    path('mydjangoproject', include('students.urls.py')),
  File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\django\urls\conf.py", line 38, in include
    urlconf_module = import_module(urlconf_module)
  File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1001, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'students.urls.py'; 'students.urls' is not a package
      
1 Answers

your issue is related to mydjangoproject.urls.py file probably your code is
include('students.urls.py')
the correct one is :
include('students.urls')

Related