Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python manage.py migrate - Error #211

Open
danfoxley opened this issue Apr 10, 2018 · 5 comments
Open

python manage.py migrate - Error #211

danfoxley opened this issue Apr 10, 2018 · 5 comments

Comments

@danfoxley
Copy link

In following steps to install on-premise, I'm stuck here.
https://docs.amon.cx/onpremise/

(env) root@amon-stg:/opt/amon# python manage.py migrate
Traceback (most recent call last):
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/opt/amon/env/lib/python3.5/site-packages/django/core/management/init.py", line 371, in execute_from_command_line
utility.execute()
File "/opt/amon/env/lib/python3.5/site-packages/django/core/management/init.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/amon/env/lib/python3.5/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "/opt/amon/env/lib/python3.5/site-packages/django/core/management/base.py", line 332, in execute
self.check()
File "/opt/amon/env/lib/python3.5/site-packages/django/core/management/base.py", line 364, in check
include_deployment_checks=include_deployment_checks,
File "/opt/amon/env/lib/python3.5/site-packages/django/core/management/commands/migrate.py", line 58, in _run_checks
issues.extend(super()._run_checks(**kwargs))
File "/opt/amon/env/lib/python3.5/site-packages/django/core/management/base.py", line 351, in _run_checks
return checks.run_checks(**kwargs)
File "/opt/amon/env/lib/python3.5/site-packages/django/core/checks/registry.py", line 73, in run_checks
new_errors = check(app_configs=app_configs)
File "/opt/amon/env/lib/python3.5/site-packages/django/core/checks/urls.py", line 40, in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
File "/opt/amon/env/lib/python3.5/site-packages/django/core/checks/urls.py", line 57, in _load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
File "/opt/amon/env/lib/python3.5/site-packages/django/utils/functional.py", line 36, in get
res = instance.dict[self.name] = self.func(instance)
File "/opt/amon/env/lib/python3.5/site-packages/django/urls/resolvers.py", line 536, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/opt/amon/env/lib/python3.5/site-packages/django/utils/functional.py", line 36, in get
res = instance.dict[self.name] = self.func(instance)
File "/opt/amon/env/lib/python3.5/site-packages/django/urls/resolvers.py", line 529, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python3.5/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 673, in _load_unlocked
File "", line 665, in exec_module
File "", line 222, in _call_with_frames_removed
File "/opt/amon/amon/urls.py", line 8, in
url(r'^api/', include('amon.apps.api.urls')),
File "/opt/amon/env/lib/python3.5/site-packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/usr/lib/python3.5/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 673, in _load_unlocked
File "", line 665, in exec_module
File "", line 222, in _call_with_frames_removed
File "/opt/amon/amon/apps/api/urls.py", line 9, in
permission_classes=[]))
File "/opt/amon/env/lib/python3.5/site-packages/rest_framework/documentation.py", line 63, in include_docs_urls
permission_classes=permission_classes,
File "/opt/amon/env/lib/python3.5/site-packages/rest_framework/documentation.py", line 26, in get_docs_view
permission_classes=permission_classes,
File "/opt/amon/env/lib/python3.5/site-packages/rest_framework/schemas/init.py", line 41, in get_schema_view
urlconf=urlconf, patterns=patterns,
File "/opt/amon/env/lib/python3.5/site-packages/rest_framework/schemas/generators.py", line 254, in init
assert coreapi, 'coreapi must be installed for schema support.'
AssertionError: coreapi must be installed for schema support.
(env) root@amon-stg:/opt/amon# ^C

@slava-vishnyakov
Copy link

Yep, also having the same error.

Full gist:
https://gist.github.com/slava-vishnyakov/1aa4f0a80f17282ecdc70b74fc25723b

  File "/opt/amon/env/lib/python3.5/site-packages/rest_framework/schemas/__init__.py", line 41, in get_schema_view
    urlconf=urlconf, patterns=patterns,
  File "/opt/amon/env/lib/python3.5/site-packages/rest_framework/schemas/generators.py", line 254, in __init__
    assert coreapi, '`coreapi` must be installed for schema support.'
AssertionError: `coreapi` must be installed for schema support.

@slava-vishnyakov
Copy link

A little research

c555418 is the first commit that doesn't have that error, but it has another (so this problem was probably introduced in c5207e3):

(env) root@test1:/opt/amon# git checkout c555418781dbb2f3c9a23d41d3df2d17aea6ba4c
Previous HEAD position was c5207e3... Refactoring
HEAD is now at c555418... Cleanup
(env) root@test1:/opt/amon# python manage.py migrate
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/amon/env/lib/python3.5/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "/opt/amon/env/lib/python3.5/site-packages/django/core/management/__init__.py", line 347, in execute
    django.setup()
  File "/opt/amon/env/lib/python3.5/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/opt/amon/env/lib/python3.5/site-packages/django/apps/registry.py", line 112, in populate
    app_config.import_models()
  File "/opt/amon/env/lib/python3.5/site-packages/django/apps/config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/opt/amon/amon/apps/dashboards/models.py", line 10, in <module>
    from amon.apps.servers.models import server_model
  File "/opt/amon/amon/apps/servers/models.py", line 7, in <module>
    from amon.apps.devices.models import interfaces_model, volumes_model
ImportError: No module named 'amon.apps.devices'

@slava-vishnyakov
Copy link

slava-vishnyakov commented Apr 18, 2018

The latest commit that I could install with instructions is 773fdca

git checkout 773fdca && \
pip install -r /opt/amon/requirements.txt && \
python manage.py migrate
...
Applying auth.0008_alter_user_username_max_length... OK
Applying sessions.0001_initial... OK
Applying users.0001_initial... OK

(However, this version has another error deep inside: No module named amon.apps.notifications.mail.backends, possible fix: change EMAIL_BACKEND in /opt/amon/amon/settings.py to EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' and restart, doesn't work for me though, [Errno 111] Connection refused)

@slava-vishnyakov
Copy link

Ok, the best workaround for now that I've come up with:

# Install old working commit
cd /opt/amon && . /opt/amon/env/bin/activate && \
git checkout 773fdca && \
pip install -r /opt/amon/requirements.txt && \
python manage.py migrate

# Fix CSRF error (if you have it)
echo >> /opt/amon/amon/settings.py
echo 'CSRF_TRUSTED_ORIGINS = [host_struct.hostname,]' >> /opt/amon/amon/settings.py

# Update to master
cd /opt/amon && . /opt/amon/env/bin/activate && \
git checkout master && \
pip install -r /opt/amon/requirements.txt && \
python manage.py migrate && \
systemctl restart amon.service

@danfoxley
Copy link
Author

danfoxley commented Apr 24, 2018

@slava-vishnyakov
Thanks for that, not sure I would have gotten there anytime soon.
Along with this: #172 I was able to get an install to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants