Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

146
Views
ModuleNotFoundError: No module named 'PyDemo.accounts'

I am working on a Django app that will host a simple index.html file:

url.py:

from django.conf.urls import url,include
from django.contrib import admin
from PyDemo.accounts.views import my_view 

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^demo/',my_view)
]

views.py:

from django.shortcuts import render_to_response
from django.template import RequestContext

# Create your views here.

def my_view(request):
    return render_to_response('index.html',locals(),context_instance=RequestContext(request))

However, when I run the app, I get the following error:

    return import_module(self.urlconf_name)
  File "C:\Users\tcssuoy\Desktop\DJANGO\mysite\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "C:\Users\tcssuoy\workspace\PyDemo\PyDemo\PyDemo\urls.py", line 18, in <module>
    from PyDemo.accounts.views import my_view 
ModuleNotFoundError: No module named 'PyDemo.accounts'
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

It seems like your project name is PyDemo and the name of the module is accounts. So try using

from accounts.views import my_view

You may find an error (underlined by red mark) that is because of your IDE so ignore it and migrate it. It will work

about 4 years ago · Santiago Trujillo Report

0

For anyone else with this issue who is migrating from Python 2 to 3 it seems to be because Python 3 is more discerning about where to find modules. @Ranjith Singhu's comment sent me in the right direction. In my case I had to change:

Python 2:

from views import MyView

Python 3 (also fine in 2):

from project_name.views import MyView
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!