Django Unhandled exception in thread started by at python manage.py runserver - python

I am running Django project on linux(Ubuntu16.04), Recently i was uninstall my os and reinstall the same OS on my system.I have some django project previously it was working very well, after installing the os and All django packages It is not running but however if i create any new django project with django-admin startproject name.. it works .
The following error i am getting
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f7ceceb5730>
Traceback (most recent call last):
File "/home/balu/Desktop/yottaasys/django-hrms/hrm_env/lib/python3.5/site-packages/django/utils/autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "/home/balu/Desktop/yottaasys/django-hrms/hrm_env/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
autoreload.raise_last_exception()
File "/home/balu/Desktop/yottaasys/django-hrms/hrm_env/lib/python3.5/site-packages/django/utils/autoreload.py", line 250, in raise_last_exception
six.reraise(*_exception)
File "/home/balu/Desktop/yottaasys/django-hrms/hrm_env/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/balu/Desktop/yottaasys/django-hrms/hrm_env/lib/python3.5/site-packages/django/utils/autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "/home/balu/Desktop/yottaasys/django-hrms/hrm_env/lib/python3.5/site-packages/django/__init__.py", line 22, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/home/balu/Desktop/yottaasys/django-hrms/hrm_env/lib/python3.5/site-packages/django/utils/log.py", line 75, in configure_logging
logging_config_func(logging_settings)
File "/usr/lib/python3.5/logging/config.py", line 795, in dictConfig
dictConfigClass(config).configure()
File "/usr/lib/python3.5/logging/config.py", line 490, in configure
raise ValueError("dictionary doesn't specify a version")
ValueError: dictionary doesn't specify a version

you are missing 'version' from your logging settings.
https://docs.python.org/3.6/library/logging.config.html#dictionary-schema-details

Related

AttributeError: module 'asyncio.coroutines' has no attribute '_is_coroutine'

I'm deploying a django app made with django channels using nginx, gunicorn and daphne. During deployment when I run python manage.py makemigrations, I get the following error. Could it be because the python version on my local machine was 3.7 and on remote ubuntu server is 3.5?
from cryptography import x509
/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/OpenSSL/crypto.py:12: CryptographyDeprecationWarning: Python 3.5 support will be dropped in the next release of cryptography. Please upgrade your Python.
from cryptography import x509
Watching for file changes with StatReloader
Exception in thread django-main-thread:
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/ubuntu/django/virtualenv2/lib/python3.5/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/django/utils/autoreload.py", line 77, in raise_last_exception
raise _exception[1]
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/django/core/management/__init__.py", line 337, in execute
autoreload.check_errors(django.setup)()
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/django/apps/registry.py", line 122, in populate
app_config.ready()
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/channels/apps.py", line 20, in ready
monkeypatch_django()
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/channels/hacks.py", line 10, in monkeypatch_django
from .management.commands.runserver import Command as RunserverCommand
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/channels/management/commands/runserver.py", line 11, in <module>
from channels.routing import get_default_application
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/channels/routing.py", line 10, in <module>
from channels.http import AsgiHandler
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/channels/http.py", line 152, in <module>
class AsgiHandler(base.BaseHandler):
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/channels/http.py", line 214, in AsgiHandler
#sync_to_async
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/asgiref/sync.py", line 375, in sync_to_async
return SyncToAsync(func, thread_sensitive=thread_sensitive)
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/asgiref/sync.py", line 262, in __init__
self._is_coroutine = asyncio.coroutines._is_coroutine
AttributeError: module 'asyncio.coroutines' has no attribute '_is_coroutine'
The error is beacause of asgiref package that uses asyncio.coroutines._is_coroutine attribute since version 3.2.2.
You can install asgiref 3.2.1 and this problem doesn't happen.
pip install asgiref==3.2.1

Django logging error: Log file not created

While running Django project, I am getting the following error:
Unhandled exception in thread started by <function wrapper at 0x7fe72b054b50>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 107, in inner_run
autoreload.raise_last_exception()
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 252, in raise_last_exception
six.reraise(*_exception)
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 17, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) File "/usr/local/lib/python2.7/dist-packages/django/utils/log.py", line 86, in configure_logging
logging_config_func(logging_settings)
File "/usr/lib/python2.7/logging/config.py", line 794, in dictConfig
dictConfigClass(config).configure()
File "/usr/lib/python2.7/logging/config.py", line 576, in configure
'%r: %s' % (name, e))
ValueError: Unable to configure handler 'ap_migration_log': [Errno 2] No such file or directory: '/home/dg/Desktop/project_dir/django_project/
module_a/management/commands/log/ap_migration_log'
One solution I found on stackoverflow is to create these files and then this error will not occur. But, why can't Django create log files on its own when required? Is there any config setting or command to make sure that logging file isn't created manually?
Make sure that if you're writing the logs to /my/log/dir/log.txt, that path exists along with the empty log.txt file. Also make sure that your directory has the right permissions to perform CRUD operations. Same goes to the file.
It's best practice to store log files in /var/log/ directory.
Have a look at https://docs.djangoproject.com/en/3.0/topics/logging/#configuring-logging for examples on how Django logging works.

Django runserver hangs at “System check identified no issues (0 silenced).” for a while

I am not able to start manage.py runserver 0.0.0.0:8000. I am using a MySQL database and I have imported all the required modules. I am trying to run quite basic application.
I am running python 3.7.3 on windows 10. Here is the error I am getting:
System check identified no issues (0 silenced).
Unhandled exception in thread started by <function check_errors.<locals>.wrapper
at 0x0000000005A89E18>
Traceback (most recent call last):
File "C:\Users\flgferre\Desktop\webapp\venv\lib\site-packages\django\utils\aut
oreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "C:\Users\flgferre\Desktop\webapp\venv\lib\site-packages\django\core\mana
gement\commands\runserver.py", line 120, in inner_run
self.check_migrations()
File "C:\Users\flgferre\Desktop\webapp\venv\lib\site-packages\django\core\mana
gement\base.py", line 442, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "C:\Users\flgferre\Desktop\webapp\venv\lib\site-packages\django\db\migrat
ions\executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "C:\Users\flgferre\Desktop\webapp\venv\lib\site-packages\django\db\migrat
ions\loader.py", line 49, in __init__
self.build_graph()
File "C:\Users\flgferre\Desktop\webapp\venv\lib\site-packages\django\db\migrat
ions\loader.py", line 212, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "C:\Users\flgferre\Desktop\webapp\venv\lib\site-packages\django\db\migrat
ions\recorder.py", line 62, in applied_migrations
return {tuple(x) for x in self.migration_qs.values_list('app', 'name')}
File "C:\Users\flgferre\Desktop\webapp\venv\lib\site-packages\django\db\models
\query.py", line 268, in __iter__
self._fetch_all()
File "C:\Users\flgferre\Desktop\webapp\venv\lib\site-packages\django\db\models
\query.py", line 1186, in _fetch_all
self._result_cache = list(self._iterable_class(self))
MemoryError
I've seen a similar MemoryError around here, but I'm not using SQLite and I've already tried using DEBUG=False.
Thank you in advance for the help.
I have just solved my problem by checking my dependencies. I believe that the code was stuck because of some kind of incompatibility among packages.

ValueError: Unable to configure handler 'null': Cannot resolve 'django.utils.log.NullHandler': No module named NullHandler

I am getting error while running python manage.py runserver of all the django projects which i have. I am using django 1.6.
My projects were running perfectly fine. Then I installed django-subdomains and django-gcm packages in my virtual environment for some implementations and the error started showing up in all the projects (may be this has something to do with the error so I mentioned). Then I uninstalled the packages but the error remains
MY error stack trace is:
Unhandled exception in thread started by <function wrapper at 0xabcddf4>
Traceback (most recent call last):
File "/home/shivam/virtual/venv/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/home/shivam/virtual/venv/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/home/shivam/virtual/venv/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
six.reraise(*_exception)
File "/home/shivam/virtual/venv/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/home/shivam/virtual/venv/local/lib/python2.7/site-packages/django/__init__.py", line 17, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/home/shivam/virtual/venv/local/lib/python2.7/site-packages/django/utils/log.py", line 71, in configure_logging
logging_config_func(logging_settings)
File "/usr/lib/python2.7/logging/config.py", line 777, in dictConfig
dictConfigClass(config).configure()
File "/usr/lib/python2.7/logging/config.py", line 575, in configure
'%r: %s' % (name, e))
ValueError: Unable to configure handler 'null': Cannot resolve 'django.utils.log.NullHandler': No module named NullHandler

Broken anydbm.py on ubuntu 10.04 with python 2.6.5?

When trying to run django-celery with beat scheduler:
bin/django celeryd -B --settings=app.development --loglevel=INFO
I got this exception:
Process Beat:
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/multiprocessing/process.py", line 237, in _bootstrap
self.run()
File "/home/user/eggs/celery-2.1.1-py2.6.egg/celery/beat.py", line 388, in run
self.service.start(embedded_process=True)
File "/home/user/eggs/celery-2.1.1-py2.6.egg/celery/beat.py", line 318, in start
humanize_seconds(self.scheduler.max_interval)))
File "/home/user/eggs/celery-2.1.1-py2.6.egg/celery/beat.py", line 358, in scheduler
self._scheduler = self.get_scheduler()
File "/home/user/eggs/celery-2.1.1-py2.6.egg/celery/beat.py", line 350, in get_scheduler
lazy=lazy)
File "/home/user/eggs/celery-2.1.1-py2.6.egg/celery/utils/__init__.py", line 362, in instantiate
return get_cls_by_name(name)(*args, **kwargs)
File "/home/user/eggs/celery-2.1.1-py2.6.egg/celery/beat.py", line 270, in __init__
Scheduler.__init__(self, *args, **kwargs)
File "/home/user/eggs/celery-2.1.1-py2.6.egg/celery/beat.py", line 146, in __init__
self.setup_schedule()
File "/home/user/eggs/celery-2.1.1-py2.6.egg/celery/beat.py", line 273, in setup_schedule
self._store = self.persistence.open(self.schedule_filename)
File "/usr/lib/python2.6/shelve.py", line 239, in open
return DbfilenameShelf(filename, flag, protocol, writeback)
File "/usr/lib/python2.6/shelve.py", line 223, in __init__
Shelf.__init__(self, anydbm.open(filename, flag), protocol, writeback)
AttributeError: 'module' object has no attribute 'open'
My own investigation led me to discovering that the anydbm python module found in
/usr/lib/python2.6/anydbm.py
is an empty file. But the python2.6.5 doc says there is an
anydbm.open(filename[, flag[, mode]])
method.
Am I missing something? I think the anydbm [ubuntu] python module is broken.
I'm using:
Ubuntu 10.04
Python 2.6.5
django-celery 2.1.1
celery installed with buildout
If /usr/lib/python2.6/anydbm.py is an empty file for you, then yes, your installation is broken. /usr/lib/python2.6/anydbm.py is the correct file, with contents, on my Ubuntu 10.04 system, with python2.6_2.6.5-1ubuntu6 installed. You'll want to make sure you have the latest package installed, and possibly reinstall it.

Categories

Resources