I'm using celery in my django app. I have setup celery as usual. But, when i try to migrate, it displays error:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.4/dist-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python3.4/dist-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.4/dist-packages/django/core/management/commands/makemigrations.py", line 111, in handle
convert_apps=app_labels or None,
File "/usr/local/lib/python3.4/dist-packages/django/db/migrations/autodetector.py", line 42, in changes
changes = self._detect_changes(convert_apps, graph)
File "/usr/local/lib/python3.4/dist-packages/django/db/migrations/autodetector.py", line 109, in _detect_changes
self.old_apps = self.from_state.render(ignore_swappable=True)
File "/usr/local/lib/python3.4/dist-packages/django/db/migrations/state.py", line 57, in render
self.apps = Apps([AppConfigStub(label) for label in sorted(self.real_apps + list(app_labels))])
File "/usr/local/lib/python3.4/dist-packages/django/apps/registry.py", line 56, in __init__
self.populate(installed_apps)
File "/usr/local/lib/python3.4/dist-packages/django/apps/registry.py", line 89, in populate
"duplicates: %s" % app_config.label)
django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: djcelery
Operations to perform:
Synchronize unmigrated apps: djcelery
Apply all migrations: auth, contenttypes, admin, djcelery, sessions
Synchronizing apps without migrations:
Creating tables...
Installing custom SQL...
Installing indexes...
Running migrations:
Applying djcelery.0001_initial...Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.4/dist-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python3.4/dist-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.4/dist-packages/django/core/management/commands/migrate.py", line 161, in handle
executor.migrate(targets, plan, fake=options.get("fake", False))
File "/usr/local/lib/python3.4/dist-packages/django/db/migrations/executor.py", line 68, in migrate
self.apply_migration(migration, fake=fake)
File "/usr/local/lib/python3.4/dist-packages/django/db/migrations/executor.py", line 96, in apply_migration
if self.detect_soft_applied(migration):
File "/usr/local/lib/python3.4/dist-packages/django/db/migrations/executor.py", line 140, in detect_soft_applied
apps = project_state.render()
File "/usr/local/lib/python3.4/dist-packages/django/db/migrations/state.py", line 57, in render
self.apps = Apps([AppConfigStub(label) for label in sorted(self.real_apps + list(app_labels))])
File "/usr/local/lib/python3.4/dist-packages/django/apps/registry.py", line 56, in __init__
self.populate(installed_apps)
File "/usr/local/lib/python3.4/dist-packages/django/apps/registry.py", line 89, in populate
"duplicates: %s" % app_config.label)
django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: djcelery
I'm using django version 1.7.5 and celery version 3.1.17. In the sample code, only djcelery app is added in the app list in settings.py .
I think that I had the same problem. I tried to find duplicate names on installed apps and even modules named djcelery inside other packages. Didn't find anything to help. In my case, the app was running fine in some machines, but was failing in others. I could even make it run, but migrate kept failing.
What solved my problem was to reinstall all my pip packages. Supposing that you have all your packages listed in a file requirements.txt:
pip uninstall -r requirements.txt
and then
pip install -r requirements.txt
I think this problem may be caused by a dead pyc or a bad dependency chain. I also found a problem with mysql for python being installed partially by pip and part by apt-get (running on Ubuntu). You can check this running your command like:
python -m pdb manage.py migrate
The error reported by pdb was related to a bad connection. Without pdb I had the same message as yours.
Tested on Ubuntu with Python 2.7.6, pip 6.1.1, django 1.7, celery 3.1.8, django-celery-3.1.16.
The problem definitely stems from the fact that djcelery appears in both unmigrated and migrated apps. From what I've seen this is usually symptomatic of having both south and django style migrations in the same app. In any case likely something is off with djcelery's migrations directory.
Related
Calling python manage.py migrate results in the following error for the auth table. I've tried deleting my DB and all migrations to start from scratch, not sure where the issue is coming from. Django version is 4.1
$ python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, generator, sessions
Running migrations:
Applying auth.0001_initial...Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "<redacted>/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_lin
e
utility.execute()
File "<redacted>/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "<redacted>/venv/lib/python3.8/site-packages/django/core/management/base.py", line 402, in run_from_argv
self.execute(*args, **cmd_options)
File "<redacted>/venv/lib/python3.8/site-packages/django/core/management/base.py", line 448, in execute
output = self.handle(*args, **options)
File "<redacted>/venv/lib/python3.8/site-packages/django/core/management/base.py", line 96, in wrapped
res = handle_func(*args, **kwargs)
File "<redacted>/venv/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 349, in handle
post_migrate_state = executor.migrate(
File "<redacted>/venv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 135, in migrate
state = self._migrate_all_forwards(
File "<redacted>/venv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
state = self.apply_migration(
File "<redacted>/venv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 255, in apply_migration
migration_recorded = True
File "<redacted>/venv/lib/python3.8/site-packages/django/db/backends/sqlite3/schema.py", line 39, in __exit__
self.connection.check_constraints()
File "<redacted>/venv/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py", line 289, in check_constraints
for column_name, (
ValueError: too many values to unpack (expected 2)
There is some issue with Django 4.1. Uninstall django and reinstall it with 4.0. This solved it for me.
pip uninstall django
pip install django==4.0
I'm getting the following error when trying to run
django-admin runserver
PS C:\Users\gasgu\PycharmProjects\djangodennisproj\devsearch> django-admin runserver
Traceback (most recent call last):
File "C:\Users\gasgu\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\gasgu\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\gasgu\PycharmProjects\djangodennisproj\venv\Scripts\django-admin.exe\__main__.py", line 7, in <module>
File "c:\users\gasgu\pycharmprojects\djangodennisproj\venv\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
utility.execute()
File "c:\users\gasgu\pycharmprojects\djangodennisproj\venv\lib\site-packages\django\core\management\__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "c:\users\gasgu\pycharmprojects\djangodennisproj\venv\lib\site-packages\django\core\management\base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "c:\users\gasgu\pycharmprojects\djangodennisproj\venv\lib\site-packages\django\core\management\commands\runserver.py", line 61, in execute
super().execute(*args, **options)
File "c:\users\gasgu\pycharmprojects\djangodennisproj\venv\lib\site-packages\django\core\management\base.py", line 398, in execute
output = self.handle(*args, **options)
File "c:\users\gasgu\pycharmprojects\djangodennisproj\venv\lib\site-packages\django\core\management\commands\runserver.py", line 68, in handle
if not settings.DEBUG and not settings.ALLOWED_HOSTS:
File "c:\users\gasgu\pycharmprojects\djangodennisproj\venv\lib\site-packages\django\conf\__init__.py", line 82, in __getattr__
self._setup(name)
File "c:\users\gasgu\pycharmprojects\djangodennisproj\venv\lib\site-packages\django\conf\__init__.py", line 63, in _setup
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
I have done a clean installation with a virtualenv, then I didi pip install django, created the project and do the runserver.
I'm running this from pycharm community and I read that I should also set an enviroment variable called DJANGO_SETTINGS_MODULE and I should put my project.settings as value. I did that and I still get the error.
I've also tried the same process from outside pycharm and just with command line I still get the same error. is there something I'm doing wrong?
Also as a note: if I do "python manage.py runserver" it does start the server. but I don't know if this is the way it should be done.
your should always use the manage.py utility after first creating the project with django-admin, basically they are the same thing but manage.py have the setting/configurations for that project..so issues like this can be avoided. if your aim of using it is more specific..please notify
After I solve the issue with "image not found" when I run python manage.py syncdb by adding "export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/" into .bash_profile.
The problem comes with python manage.py runserver
Does anyone know how to solve OSError(Errno 20)?
System check identified no issues (0 silenced).
October 07, 2014 - 18:19:56
Django version 1.8, using settings 'dbtest.settings'
Starting development server at http:/127.0.0.1:8000/
Quit the server with CONTROL-C.
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/Django-1.8-py2.7.egg/django/core/management/__init__.py", line 330, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/Django-1.8-py2.7.egg/django/core/management/__init__.py", line 322, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/Django-1.8-py2.7.egg/django/core/management/base.py", line 363, in run_from_argv
self.execute(*args, **cmd_options)
File "/Library/Python/2.7/site-packages/Django-1.8-py2.7.egg/django/core/management/base.py", line 412, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.7/site-packages/Django-1.8-py2.7.egg/django/core/management/commands/runserver.py", line 80, in handle
self.run(**options)
File "/Library/Python/2.7/site-packages/Django-1.8-py2.7.egg/django/core/management/commands/runserver.py", line 89, in run
autoreload.main(self.inner_run, None, options)
File "/Library/Python/2.7/site-packages/Django-1.8-py2.7.egg/django/utils/autoreload.py", line 320, in main
reloader(wrapped_main_func, args, kwargs)
File "/Library/Python/2.7/site-packages/Django-1.8-py2.7.egg/django/utils/autoreload.py", line 286, in python_reloader
reloader_thread()
File "/Library/Python/2.7/site-packages/Django-1.8-py2.7.egg/django/utils/autoreload.py", line 262, in reloader_thread
change = fn()
File "/Library/Python/2.7/site-packages/Django-1.8-py2.7.egg/django/utils/autoreload.py", line 200, in code_changed
stat = os.stat(filename)
OSError: [Errno 20] Not a directory: '/Library/Python/2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.9-intel.egg/MySQLdb/converters.py'
I just realize that I install both mysql-python and mysql-connector-python packages.
By changing the database 'ENGINE' setting from 'django.db.backends.mysql' to 'mysql.connector.django', the issue is solved.
Lesson learned here: I should probably use virtualenv to try different python package.
When I try to migrate my db, I'm getting this error:
Running migrations for easy_thumbnails:
- Nothing to migrate.
- Loading initial data for easy_thumbnails.
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.7/site-packages/south/management/commands/migrate.py", line 111, in handle
ignore_ghosts = ignore_ghosts,
File "/Library/Python/2.7/site-packages/south/migration/__init__.py", line 233, in migrate_app
migrator.load_initial_data(target, db=database)
File "/Library/Python/2.7/site-packages/south/migration/migrators.py", line 222, in load_initial_data
self.post_1_6(target, db)
File "/Library/Python/2.7/site-packages/south/migration/migrators.py", line 240, in post_1_6
old_cache = django.db.models.loading.cache
AttributeError: 'module' object has no attribute 'loading'
Apps versions are:
Django 1.6.2
Easy thumbnails 1.4
Mptt 0.5.5
Pymorphy 0.5.6
Python 2.7.5
Pytils 0.3dev
South 0.8.4
Suit 0.2.5
It's looks like not easy_thumbnails problem, because when I try to migrate my django-allauth it raises the same error.
Please, help me!
It seems like your django package was broken. Check that there is python2.7/site-packages/django/db/models/loading.py file in your environment. Or just reinstall django package.
pip install -U --force-reinstall django
I have a simple django project. Installed python,django and mysql database in my ubuntu to run this project. In order to run my project I am trying to sync database first. But when I am trying command "python manage.py syndb" I am getting following errors:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 429, in execute_from_command_line
utility.execute()
File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 252, in fetch_command
app_name = get_commands()[subcommand]
File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 101, in get_commands
apps = settings.INSTALLED_APPS
File "/usr/lib/python2.7/dist-packages/django/utils/functional.py", line 276, in __getattr__
self._setup()
File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 139, in __init__
logging_config_func(self.LOGGING)
File "/usr/lib/python2.7/logging/config.py", line 777, in dictConfig
dictConfigClass(config).configure()
File "/usr/lib/python2.7/logging/config.py", line 562, in configure
'filter %r: %s' % (name, e))
ValueError: Unable to configure filter 'require_debug_false': Cannot resolve 'django.utils.log.RequireDebugFalse': No module named RequireDebugFalse
I am very new to python and django. doing it first time..
django.utils.log.RequireDebugFalse appeared in Django 1.4.0. Could it be you have an older Django version installed ?
As you stated in the comment, you installed Django from your distro's repository. Those versions are often old, and indeed it looks like you have installed version 1.3, which is now three versions out of date.
You should remove that version (with apt-get remove) and install the current version from the Python package index, via pip install django. You will probably need to install pip first, which you can do with apt-get.