Django Server Just Stops - python

I just got done upgrading to Django 2.2.3 from version 2.0.
For some reason the system will just stop working when going to a new page. I might go one or to pages and then the server stops.
I am also using Cookiecutter.
Below is a typical message that I am receiving. Though it changes.
it was acting strange before this - why I upgraded.
I checked all my migrations. Reinstalled Django. Using Pycharm.
Thanks.
[17/Jul/2019 08:26:04] "GET /account/login/ HTTP/1.1" 200 13126
[17/Jul/2019 08:26:04] "GET /static/CACHE/css/app.8e450f098f62.css HTTP/1.1" 200 323872
AttributeError: cffi library '_ffi' has no function, constant or global variable named '__spec__'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/benson/PycharmProjects/myanalysis/manage.py", line 29, in <module>
execute_from_command_line(sys.argv)
File "/Users/benson/PycharmProjects/myanalysis/v_env/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/Users/benson/PycharmProjects/myanalysis/v_env/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/benson/PycharmProjects/myanalysis/v_env/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/benson/PycharmProjects/myanalysis/v_env/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 60, in execute
super().execute(*args, **options)
File "/Users/benson/PycharmProjects/myanalysis/v_env/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/Users/benson/PycharmProjects/myanalysis/v_env/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 95, in handle
self.run(**options)
File "/Users/benson/PycharmProjects/myanalysis/v_env/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "/Users/benson/PycharmProjects/myanalysis/v_env/lib/python3.6/site-packages/django/utils/autoreload.py", line 579, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "/Users/benson/PycharmProjects/myanalysis/v_env/lib/python3.6/site-packages/django/utils/autoreload.py", line 564, in start_django
reloader.run(django_main_thread)
File "/Users/benson/PycharmProjects/myanalysis/v_env/lib/python3.6/site-packages/django/utils/autoreload.py", line 275, in run
self.run_loop()
File "/Users/benson/PycharmProjects/myanalysis/v_env/lib/python3.6/site-packages/django/utils/autoreload.py", line 281, in run_loop
next(ticker)
File "/Users/benson/PycharmProjects/myanalysis/v_env/lib/python3.6/site-packages/django/utils/autoreload.py", line 321, in tick
state.update(self.loop_files(state, previous_timestamp))
File "/Users/benson/PycharmProjects/myanalysis/v_env/lib/python3.6/site-packages/django/utils/autoreload.py", line 328, in loop_files
for path, mtime in self.snapshot_files():
File "/Users/benson/PycharmProjects/myanalysis/v_env/lib/python3.6/site-packages/django/utils/autoreload.py", line 348, in snapshot_files
for file in self.watched_files():
File "/Users/benson/PycharmProjects/myanalysis/v_env/lib/python3.6/site-packages/django/utils/autoreload.py", line 241, in watched_files
yield from iter_all_python_module_files()
File "/Users/benson/PycharmProjects/myanalysis/v_env/lib/python3.6/site-packages/django/utils/autoreload.py", line 103, in iter_all_python_module_files
return iter_modules_and_files(modules, frozenset(_error_files))
File "/Users/benson/PycharmProjects/myanalysis/v_env/lib/python3.6/site-packages/django/utils/autoreload.py", line 114, in iter_modules_and_files
if not isinstance(module, ModuleType) or getattr(module, '__spec__', None) is None:
SystemError: <built-in function getattr> returned a result with an error set

Related

Django - can't start server

I am getting the following error when I try to start the server locally (./manage.py runserver).
Posting the question after spending 5 hours of searching solution.
Attached the error stack. I am using Django 2.2.2.
Watching for file changes with StatReloader
Performing system checks...
Traceback (most recent call last):
File "./manage.py", line 26, in <module>
execute_from_command_line(sys.argv)
File "/home/santhosh/Desktop/working_dir/piccolo/venv/lib/python3.5/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/santhosh/Desktop/working_dir/piccolo/venv/lib/python3.5/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/santhosh/Desktop/working_dir/piccolo/venv/lib/python3.5/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/santhosh/Desktop/working_dir/piccolo/venv/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 60, in execute
super().execute(*args, **options)
File "/home/santhosh/Desktop/working_dir/piccolo/venv/lib/python3.5/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/home/santhosh/Desktop/working_dir/piccolo/venv/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 95, in handle
self.run(**options)
File "/home/santhosh/Desktop/working_dir/piccolo/venv/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "/home/santhosh/Desktop/working_dir/piccolo/venv/lib/python3.5/site-packages/django/utils/autoreload.py", line 585, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "/home/santhosh/Desktop/working_dir/piccolo/venv/lib/python3.5/site-packages/django/utils/autoreload.py", line 570, in start_django
reloader.run(django_main_thread)
File "/home/santhosh/Desktop/working_dir/piccolo/venv/lib/python3.5/site-packages/django/utils/autoreload.py", line 288, in run
self.run_loop()
File "/home/santhosh/Desktop/working_dir/piccolo/venv/lib/python3.5/site-packages/django/utils/autoreload.py", line 294, in run_loop
next(ticker)
File "/home/santhosh/Desktop/working_dir/piccolo/venv/lib/python3.5/site-packages/django/utils/autoreload.py", line 334, in tick
for filepath, mtime in self.snapshot_files():
File "/home/santhosh/Desktop/working_dir/piccolo/venv/lib/python3.5/site-packages/django/utils/autoreload.py", line 350, in snapshot_files
for file in self.watched_files():
File "/home/santhosh/Desktop/working_dir/piccolo/venv/lib/python3.5/site-packages/django/utils/autoreload.py", line 249, in watched_files
yield from iter_all_python_module_files()
File "/home/santhosh/Desktop/working_dir/piccolo/venv/lib/python3.5/site-packages/django/utils/autoreload.py", line 103, in iter_all_python_module_files
return iter_modules_and_files(modules, frozenset(_error_files))
File "/home/santhosh/Desktop/working_dir/piccolo/venv/lib/python3.5/site-packages/django/utils/autoreload.py", line 116, in iter_modules_and_files
if module.__name__ == '__main__':
File "/usr/lib/python3/dist-packages/py/_apipkg.py", line 171, in __getattribute__
return getattr(getmod(), name)
File "/usr/lib/python3/dist-packages/py/_error.py", line 43, in __getattr__
raise AttributeError(name)
AttributeError: __name__
Thanks in advance.

Django-MarkItUp: Exception while starting tests (AttributeError: 'str' object has no attribute 'raw')

I can't find the solution for an exception when I start my tests which suddenly accured while coding. The website still works fine with runserver. Here is the full traceback:
Traceback (most recent call last):
File "manage.py", line 10, in <module
execute_from_command_line(sys.argv)
File "…/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "…/lib/python3.5/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "…/lib/python3.5/site-packages/django/core/management/commands/test.py", line 29, in run_from_argv
super(Command, self).run_from_argv(argv)
File "…/lib/python3.5/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "…/lib/python3.5/site-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "…/lib/python3.5/site-packages/django/core/management/commands/test.py", line 72, in handle
failures = test_runner.run_tests(test_labels)
File "…/lib/python3.5/site-packages/django/test/runner.py", line 549, in run_tests
old_config = self.setup_databases()
File "…/lib/python3.5/site-packages/django/test/runner.py", line 499, in setup_databases
self.parallel, **kwargs
File "…/lib/python3.5/site-packages/django/test/runner.py", line 743, in setup_databases
serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
File "…/lib/python3.5/site-packages/django/db/backends/base/creation.py", line 78, in create_test_db
self.connection._test_serialized_contents = self.serialize_db_to_string()
File "…/lib/python3.5/site-packages/django/db/backends/base/creation.py", line 122, in serialize_db_to_string
serializers.serialize("json", get_objects(), indent=None, stream=out)
File "…/lib/python3.5/site-packages/django/core/serializers/__init__.py", line 129, in serialize
s.serialize(queryset, **options)
File "…/lib/python3.5/site-packages/django/core/serializers/base.py", line 88, in serialize
self.handle_field(obj, field)
File "…/lib/python3.5/site-packages/django/core/serializers/python.py", line 55, in handle_field
self._current[field.name] = field.value_to_string(obj)
File "…/lib/python3.5/site-packages/markitup/fields.py", line 103, in value_to_string
return value.raw
AttributeError: 'str' object has no attribute 'raw'
Normally I try to narrow the issue down myself. But in this case I don't get anywhere.
I didn't update any packages. These are the packages in question:
Django (1.10.7)
django-markitup (3.0.0)
(The exception disappears when I replace my MarkupField with a standard TextField in models.py.)
Update: The error appears when I use --keepdb successively.
Seems you can fix it by
class MyMarkupField(MarkupField):
def value_to_string(self, obj):
value = self._get_val_from_obj(obj)
if hasattr(value, "raw"):
return value.raw
return value
Then
field = MyMarkupField()
Actually i dont know why this error is coming.

Socorro - django.db.utils.OperationalError: unable to open database file

I am trying to install Socorro on fresh Ubuntu 10.04 (Amazon EC2). I am following this manual and I am on the step 6.2.8, and I am having a problem with following command:
./manage.py syncdb --noinput
This is the error:
django.db.utils.OperationalError: unable to open database file
What seems to be the problem?
And this is the hole log:
Syncing...
Raven is not configured (logging is disabled). Please see the documentation for more information.
Traceback (most recent call last):
File "./manage.py", line 13, in <module>
manage.main()
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/funfactory/manage.py", line 144, in main
execute_from_command_line(argv)
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/core/management/base.py", line 415, in handle
return self.handle_noargs(**options)
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/south/management/commands/syncdb.py", line 92, in handle_noargs
syncdb.Command().execute(**options)
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/raven/contrib/django/management/__init__.py", line 37, in new_execute
return original_func(self, *args, **kwargs)
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/core/management/base.py", line 415, in handle
return self.handle_noargs(**options)
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 57, in handle_noargs
cursor = connection.cursor()
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 160, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 132, in _cursor
self.ensure_connection()
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 127, in ensure_connection
self.connect()
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/db/utils.py", line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 127, in ensure_connection
self.connect()
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 115, in connect
self.connection = self.get_new_connection(conn_params)
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 347, in get_new_connection
conn = Database.connect(**conn_params)
django.db.utils.OperationalError: unable to open database file

Error in paster setup-app development.ini?

I am trying to install MediaCore on my machine running CentOS as soon as I fire this coomand
on command prompt it gives me an error
[root#localhost mediacore-mediacore-e6e7419]# paster setup-app development.ini Traceback (most recent call last):
File "/usr/bin/paster", line 7, in ?
sys.exit( File "/usr/lib/python2.4/site-packages/PasteScript-1.7.3-py2.4.egg/paste/script/command.py", line 84, in run invoke(command, command_name, options, args[1:])
File "/usr/lib/python2.4/site-packages/PasteScript-1.7.3-py2.4.egg/paste/script/command.py", line 123, in invoke exit_code = runner.run(args)
File "/usr/lib/python2.4/site-packages/PasteScript-1.7.3-py2.4.egg/paste/script/appinstall.py", line 68, in run return super(AbstractInstallCommand, self).run(new_args)
File "/usr/lib/python2.4/site-packages/PasteScript-1.7.3-py2.4.egg/paste/script/command.py", line 218, in run result = self.command()
File "/usr/lib/python2.4/site-packages/PasteScript-1.7.3-py2.4.egg/paste/script/appinstall.py", line 447, in command conf = appconfig(config_spec, relative_to=os.getcwd()) File "/usr/lib/python2.4/site-packages/PasteDeploy-1.3.3-py2.4.egg/paste/deploy/loadwsgi.py", line 215, in appconfig global_conf=global_conf)
File "/usr/lib/python2.4/site-packages/PasteDeploy-1.3.3-py2.4.egg/paste/deploy/loadwsgi.py", line 248, in loadcontext global_conf=global_conf)
File "/usr/lib/python2.4/site-packages/PasteDeploy-1.3.3-py2.4.egg/paste/deploy/loadwsgi.py", line 278, in _loadconfig return loader.get_context(object_type, name, global_conf) File "/usr/lib/python2.4/site-packages/PasteDeploy-1.3.3-py2.4.egg/paste/deploy/loadwsgi.py", line 409, in get_context section)
File "/usr/lib/python2.4/site-packages/PasteDeploy-1.3.3-py2.4.egg/paste/deploy/loadwsgi.py", line 430, in _context_from_use context = self.get_context(
File "/usr/lib/python2.4/site-packages/PasteDeploy-1.3.3-py2.4.egg/paste/deploy/loadwsgi.py", line 361, in get_context global_conf=global_conf)
File "/usr/lib/python2.4/site-packages/PasteDeploy-1.3.3-py2.4.egg/paste/deploy/loadwsgi.py", line 248, in loadcontext global_conf=global_conf)
File "/usr/lib/python2.4/site-packages/PasteDeploy-1.3.3-py2.4.egg/paste/deploy/loadwsgi.py", line 285, in _loadegg return loader.get_context(object_type, name, global_conf) File "/usr/lib/python2.4/site-packages/PasteDeploy-1.3.3-py2.4.egg/paste/deploy/loadwsgi.py", line 560, in get_context entry_point, protocol, ep_name = self.find_egg_entry_point( File "/usr/lib/python2.4/site-packages/PasteDeploy-1.3.3-py2.4.egg/paste/deploy/loadwsgi.py", line 587, in find_egg_entry_point
possible.append((entry.load(), protocol, entry.name))
File "/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/pkg_resources.py", line 1954, in load entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/root/medi/mediacore-mediacore-e6e7419/mediacore/config/middleware.py", line 19, in ? from beaker.middleware import SessionMiddleware
File "/usr/lib/python2.4/site-packages/Beaker-1.6.1-py2.4.egg/beaker/middleware.py", line 11, in ? from beaker.cache import CacheManager
File "/usr/lib/python2.4/site-packages/Beaker-1.6.1-py2.4.egg/beaker/cache.py", line 17, in ? import beaker.ext.memcached as memcached
File "/usr/lib/python2.4/site-packages/Beaker-1.6.1-py2.4.egg/beaker/ext/memcached.py", line 136 with self.pool.reserve() as mc:
^
SyntaxError: invalid syntax
Any Help will be greatly appreciated.
Thanks
The with statement only appeared in python2.5, and you're using python2.4. It looks that Beaker is not really compatible with python2.4.

error when running python manage.py syncdb

I have a new server just installed. Everything seems to be fine but when i run:
python manage.py syncdb
it generates follow error:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 351, in handle
return self.handle_noargs(**options)
File "/usr/lib/python2.6/site-packages/django/core/management/commands/syncdb.py", line 109, in handle_noargs
emit_post_sync_signal(created_models, verbosity, interactive, db)
File "/usr/lib/python2.6/site-packages/django/core/management/sql.py", line 190, in emit_post_sync_signal
interactive=interactive, db=db)
File "/usr/lib/python2.6/site-packages/django/dispatch/dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)
File "/usr/lib/python2.6/site-packages/django/contrib/auth/management/__init__.py", line 51, in create_permissions
content_type=ctype
File "/usr/lib/python2.6/site-packages/django/db/models/manager.py", line 138, in create
return self.get_query_set().create(**kwargs)
File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 360, in create
obj.save(force_insert=True, using=self.db)
File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 460, in save
self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 553, in save_base
result = manager._insert(values, return_id=update_pk, using=using)
File "/usr/lib/python2.6/site-packages/django/db/models/manager.py", line 195, in _insert
return insert_query(self.model, values, **kwargs)
File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 1436, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 791, in execute_sql
cursor = super(SQLInsertCompiler, self).execute_sql(None)
File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
cursor.execute(sql, params)
File "/usr/lib/python2.6/site-packages/django/db/backends/util.py", line 34, in execute
return self.cursor.execute(sql, params)
File "/usr/lib/python2.6/site-packages/django/db/backends/mysql/base.py", line 86, in execute
return self.cursor.execute(query, args)
File "/usr/lib/python2.6/site-packages/MySQLdb/cursors.py", line 175, in execute
if not self._defer_warnings: self._warning_check()
File "/usr/lib/python2.6/site-packages/MySQLdb/cursors.py", line 89, in _warning_check
warn(w[-1], self.Warning, 3)
_mysql_exceptions.Warning: Incorrect string value: '\xE6\x99\xAF\xE9\xBB\x9E...' for column 'name' at row 1
All the tables and fields, in fact, created automatically without observable problem. I just wanna get rid of this error becoz the same thing does not happen in my old server with exactly the same project running on it.
So I am answering it here so that other people can have answer of same problem:
As said by Bill Kary:
He have solved this himself. Change all the collation of ALL tables AND fields to utf (utf8_general_ci) stops the error beautifully.

Categories

Resources