Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

147
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda