0

I'm moving a very simple django app from my desktop pc to a virtualbox server. I have copied the hole proyect, except for the virtualenv sources folder. Then, i've created a virtualenv and installed dependencies in the same way. When i run manage.py a circular reference error cames in claming The included URLconf 'pmkwebPdf.urls' does not appear to have any patterns in it

This is the project dir:

PmkwebPdf
    media
    pmkwebPdf
        __init.py
        settings.py
        urls.py
        wsgi.py
    src
        migrations
            ...
        processor
            ...
        __init__.py
        admin.py
        apps.py
        models.py
        tests.py
        urls.py
        views.py
    templates
        ...
    venv
        ...
    db.sqlite3
    manage.py

It's certanly an error with the urlpatterns. So i did this.

pmkWebPdf.urls

from django.contrib import admin
#from django.urls import path, include

urlpatterns = [
    #path('', include('src.urls')),
    path('admin/', admin.site.urls),
]

In this file, if i remove the path('', include('src.urls')), and its dependecies the error is gone.

src/urls.py

from django.conf.urls.static import static
from django.urls import path

from pmkwebPdf import settings
#from src.views import index

urlpatterns = [
    #path('', index, name='index')
]

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

After leaving the pmkWebPdf.urls without the lines commented, i discovered that, in this file, if i leave the urlpatters empty and remove the from src.views import index line. The server runs.

I've created the same proyect in both my desktop pc and my virtual machine following the same procedure and the result is different.

There are differences between the env The virtual machine must run on 32-bit. So the difference is that it runs python 3.5.2 vs 3.6.8 (the version of python in my desktop 64-bit pc). However, venv dependencies are exactly the same.

This is traceback of the error

Traceback (most recent call last):
  File "/home/hernan/pmk/pmkwebPdf/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 581, in url_patterns
    iter(patterns)
TypeError: 'module' object is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "/home/hernan/pmk/pmkwebPdf/venv/lib/python3.5/site-packages/django/utils/autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "/home/hernan/pmk/pmkwebPdf/venv/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
    self.check(display_num_errors=True)
  File "/home/hernan/pmk/pmkwebPdf/venv/lib/python3.5/site-packages/django/core/management/base.py", line 390, in check
    include_deployment_checks=include_deployment_checks,
  File "/home/hernan/pmk/pmkwebPdf/venv/lib/python3.5/site-packages/django/core/management/base.py", line 377, in _run_checks
    return checks.run_checks(**kwargs)
  File "/home/hernan/pmk/pmkwebPdf/venv/lib/python3.5/site-packages/django/core/checks/registry.py", line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/home/hernan/pmk/pmkwebPdf/venv/lib/python3.5/site-packages/django/core/checks/urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "/home/hernan/pmk/pmkwebPdf/venv/lib/python3.5/site-packages/django/core/checks/urls.py", line 23, in check_resolver
    return check_method()
  File "/home/hernan/pmk/pmkwebPdf/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 398, in check
    for pattern in self.url_patterns:
  File "/home/hernan/pmk/pmkwebPdf/venv/lib/python3.5/site-packages/django/utils/functional.py", line 80, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/hernan/pmk/pmkwebPdf/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 588, in url_patterns
    raise ImproperlyConfigured(msg.format(name=self.urlconf_name))
django.core.exceptions.ImproperlyConfigured: The included URLconf 'pmkwebPdf.urls' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.

Any ideas on what may be causing this or why is it happening?

Hernan
  • 1,149
  • 1
  • 11
  • 29
  • Did you name a file `urlpatterns.py`, or name a folder `urlpatterns`? If you did, pick a different name. – user2357112 Aug 17 '19 at 05:00
  • Also, have you checked your code for circular imports? We certainly don't have enough information to check it from here. – user2357112 Aug 17 '19 at 05:02
  • No folder named urlpatterns. But, if it's a circular import, why would i get this error in the first enviroment and not in the second? It's the same code – Hernan Aug 17 '19 at 06:22

1 Answers1

0

The problem was on control characters.

The first enviroment got CR and the second LF.

More info about the meaning and difference between this two can be found in this answer.

Hernan
  • 1,149
  • 1
  • 11
  • 29