-1

I have been handed over an application which is built in Python - Django. I need to support it. There was no handover or anything like that. Pitty Me! I am new to this language and framework. When I try to run the server with python manage.py runserver I get following errors:

Unhandled exception in thread started by .wrapper at 0x108f48e18> Traceback (most recent call last): File "/Users/atariq/Sites/Python_Stuff/123/venv/lib/python3.7/site-packages/django/utils/autoreload.py", line 228, in wrapper fn(*args, **kwargs) File "/Users/atariq/Sites/Python_Stuff/123/venv/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 116, in inner_run autoreload.raise_last_exception() File "/Users/atariq/Sites/Python_Stuff/123/venv/lib/python3.7/site-packages/django/utils/autoreload.py", line 251, in raise_last_exception six.reraise(*_exception) File "/Users/atariq/Sites/Python_Stuff/123/venv/lib/python3.7/site-packages/django/utils/six.py", line 685, in reraise raise value.with_traceback(tb) File "/Users/atariq/Sites/Python_Stuff/123/venv/lib/python3.7/site-packages/django/utils/autoreload.py", line 228, in wrapper fn(*args, **kwargs) File "/Users/atariq/Sites/Python_Stuff/123/venv/lib/python3.7/site-packages/django/init.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "/Users/atariq/Sites/Python_Stuff/123/venv/lib/python3.7/site-packages/django/apps/registry.py", line 85, in populate app_config = AppConfig.create(entry) File "/Users/atariq/Sites/Python_Stuff/123/venv/lib/python3.7/site-packages/django/apps/config.py", line 94, in create module = import_module(entry) File "/Users/atariq/Sites/Python_Stuff/123/venv/lib/python3.7/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 967, in _find_and_load_unlocked File "", line 677, in _load_unlocked File "", line 728, in exec_module File "", line 219, in _call_with_frames_removed File "/Users/atariq/Sites/Python_Stuff/123/venv/lib/python3.7/site-packages/django/contrib/admin/init.py", line 4, in from django.contrib.admin.filters import ( File "/Users/atariq/Sites/Python_Stuff/123/venv/lib/python3.7/site-packages/django/contrib/admin/filters.py", line 10, in from django.contrib.admin.options import IncorrectLookupParameters File "/Users/atariq/Sites/Python_Stuff/123/venv/lib/python3.7/site-packages/django/contrib/admin/options.py", line 12, in from django.contrib.admin import helpers, widgets File "/Users/atariq/Sites/Python_Stuff/123/venv/lib/python3.7/site-packages/django/contrib/admin/widgets.py", line 152 '%s=%s' % (k, v) for k, v in params.items(), ^

I am unable to understand what it says. Can someone guide me over it? I have installed all the required packages for the project with pip.

I am on Python 3.7 and using virtualenv.

UPDATE

I came to know that project works with Python 3.6, so I installed it and still getting same type of error log. Pip Freeze gave me this:

asgiref==1.1.2
attrs==18.2.0
autobahn==18.11.2
Automat==0.7.0
certifi==2018.11.29
channels==1.1.6
chardet==3.0.4
constantly==15.1.0
coreapi==2.3.3
coreschema==0.0.4
daphne==1.3.0
defusedxml==0.5.0
dj-database-url==0.5.0
Django==1.11.12
django-allauth==0.32.0
django-cors-headers==2.4.0
django-debug-toolbar==1.9.1
django-filter==2.0.0
django-jsonview==1.2.0
django-prometheus==1.0.13
django-pyodbc-azure==1.11.12.1
django-watchman==0.15.0
djangorestframework==3.7.7
djangorestframework-camel-case==0.2.0
djangorestframework-jwt==1.11.0
djangorestframework-xml==1.3.0
docutils==0.13.1
drf-yasg==1.6.2
future==0.17.1
gevent==1.2.2
greenlet==0.4.15
hyperlink==18.0.0
idna==2.7
incremental==17.5.0
inflection==0.3.1
itypes==1.1.0
Jinja2==2.10
ldap3==2.3
MarkupSafe==1.1.0
oauthlib==2.1.0
openapi-codec==1.3.2
Pillow==5.3.0
prometheus-client==0.5.0
pyasn1==0.4.4
Pygments==2.3.0
PyHamcrest==1.9.0
PyJWT==1.7.1
pyodbc==4.0.23
python-dateutil==2.6.1
python3-openid==3.1.0
pytz==2018.7
raven==6.7.0
requests==2.20.1
requests-oauthlib==1.0.0
ruamel.yaml==0.15.81
six==1.11.0
sqlparse==0.2.4
Twisted==18.9.0
txaio==18.8.1
ua-parser==0.8.0
uritemplate==3.0.0
urllib3==1.24.1
user-agents==1.1.0
uWSGI==2.0.17
zope.interface==4.6.0

Manage.py

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ProjectName.settings.development")
    try:
        from django.core.management import execute_from_command_line
    except ImportError:
        # The above import may fail for some other reason. Ensure that the
        # issue is really that Django is missing to avoid masking other
        # exceptions on Python 2.
        try:
            import django
        except ImportError:
            raise ImportError(
                "Couldn't import Django. Are you sure it's installed and "
                "available on your PYTHONPATH environment variable? Did you "
                "forget to activate a virtual environment?"
            )
        raise
    execute_from_command_line(sys.argv)

Regards

Awais Tariq
  • 7,724
  • 5
  • 31
  • 54
  • What Django version do you use? Could you share from `pip freeze`? – Sergey Pugach Dec 10 '18 at 10:19
  • Updated the question after your comment. – Awais Tariq Dec 10 '18 at 13:16
  • You are using Django 1.11.12. Only Django 1.11.17 started to be compatible with Python 3.7. Info from official Django docs: https://docs.djangoproject.com/en/dev/faq/install/#what-python-version-can-i-use-with-django I suggest to use Python 3.6 if you need Django 1.11 or update Django to 2 version. – Sergey Pugach Dec 10 '18 at 15:09
  • As far as you installed python 3.6 did you recreated virtual env and installed all those packages there again? – Sergey Pugach Dec 10 '18 at 15:18

3 Answers3

3

It seems to be incompatibility of Python 3.7 and your current version of Django. You can find more details in similar question What I can suggest is to upgrade your Django 2 or use Python 3.6.

Here you can see that Python 3.7 is compatible with Django 1.11.17 version.

Sergey Pugach
  • 5,561
  • 1
  • 16
  • 31
0

Can we see the code u a=have written in manage.py Who ever tries python for the first tym they does a very basic mistake of inidnantion. Though it ll be inditnation error for sometime it will throw some other prioritized error. !CHECK FOR INDINANATION

Harsha Biyani
  • 7,049
  • 9
  • 37
  • 61
0

Thanks guys for the help.

After a lot of headbang, I came to know that there were a lot of modules missing from req.txt file which were required to build the project. They were mentioned in some other file.

After installing all the required modules, and running the migrations, I was able to run the project.

Awais Tariq
  • 7,724
  • 5
  • 31
  • 54