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

Could not import 'karrio.server.core.authentication.TokenBasicAuthentication' #233

Closed
adrianmihaila opened this issue Aug 8, 2022 · 1 comment

Comments

@adrianmihaila
Copy link

adrianmihaila commented Aug 8, 2022

Describe the bug
I followed the installation steps from here: https://docs.karrio.io/installation, but the server throws the following exception ImportError: Could not import 'karrio.server.core.authentication.TokenBasicAuthentication' for API setting 'DEFAULT_AUTHENTICATION_CLASSES'. ModuleNotFoundError: No module named 'yaml'.

To Reproduce
Steps to reproduce the behavior:

  1. Create .env file with these values
DEBUG_MODE=True
ALLOWED_HOSTS=*
DATABASE_HOST=db
DATABASE_PORT=5432
DATABASE_NAME=db
DATABASE_USERNAME=postgres
DATABASE_PASSWORD=postgres
DETACHED_WORKER=False
  1. Create docker-compose.yml file
version: '3'

services:
  karrio:
    container_name: karrio
    image: karrio/server:2022.6
    restart: unless-stopped
    ports:
      - "5002:5002"
    env_file: .env
    depends_on:
      - db
    networks:
      - db_network
      - web_network
    volumes:
      - karriostatics:/karrio/static

  dashboard:
    container_name: dashboard
    image: karrio/dashboard:2022.6
    ports:
      - "3000:3000"
    environment:
      - 'NEXT_PUBLIC_KARRIO_API_URL=http://host.docker.internal:5002'
      - 'NEXTAUTH_URL=http://host.docker.internal:3000'
      - JWT_SECRET="n*s-ex6@ex_r1i%bk=3jd)p+lsick5bi*90!mbk7rc3iy_op1r"
    networks:
      - web_network

  db:
    container_name: db
    image: postgres
    restart: unless-stopped
    environment:
      POSTGRES_DB: "db"
      POSTGRES_USER: "postgres"
      POSTGRES_PASSWORD: "postgres"
      PGDATA: /var/lib/postgresql/data/sandbox
    networks:
      - db_network

volumes:
  karriostatics:
  karrio-db:

networks:
  db_network:
  web_network:
  1. Run docker-compose up

Entire log

karrio     | Traceback (most recent call last):
karrio     |   File "/karrio/venv/lib/python3.8/site-packages/rest_framework/settings.py", line 177, in import_from_string
karrio     |     return import_string(val)
karrio     |   File "/karrio/venv/lib/python3.8/site-packages/django/utils/module_loading.py", line 17, in import_string
karrio     |     module = import_module(module_path)
karrio     |   File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
karrio     |     return _bootstrap._gcd_import(name[level:], package, level)
karrio     |   File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
karrio     |   File "<frozen importlib._bootstrap>", line 991, in _find_and_load
karrio     |   File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
karrio     |   File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
karrio     |   File "<frozen importlib._bootstrap_external>", line 843, in exec_module
karrio     |   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
karrio     |   File "/karrio/venv/lib/python3.8/site-packages/karrio/server/core/authentication.py", line 1, in <module>
karrio     |     import yaml
karrio     | ModuleNotFoundError: No module named 'yaml'
karrio     |
karrio     | During handling of the above exception, another exception occurred:
karrio     |
karrio     | Traceback (most recent call last):
karrio     |   File "/karrio/venv/bin/karrio", line 8, in <module>
karrio     |     sys.exit(main())
karrio     |   File "/karrio/venv/lib/python3.8/site-packages/karrio/server/__main__.py", line 17, in main
karrio     |     execute_from_command_line(sys.argv)
karrio     |   File "/karrio/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
karrio     |     utility.execute()
karrio     |   File "/karrio/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
karrio     |     django.setup()
karrio     |   File "/karrio/venv/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
karrio     |     apps.populate(settings.INSTALLED_APPS)
karrio     |   File "/karrio/venv/lib/python3.8/site-packages/django/apps/registry.py", line 114, in populate
karrio     |     app_config.import_models()
karrio     |   File "/karrio/venv/lib/python3.8/site-packages/django/apps/config.py", line 301, in import_models
karrio     |     self.models_module = import_module(models_module_name)
karrio     |   File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
karrio     |     return _bootstrap._gcd_import(name[level:], package, level)
karrio     |   File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
karrio     |   File "<frozen importlib._bootstrap>", line 991, in _find_and_load
karrio     |   File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
karrio     |   File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
karrio     |   File "<frozen importlib._bootstrap_external>", line 843, in exec_module
karrio     |   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
karrio     |   File "/karrio/venv/lib/python3.8/site-packages/karrio/server/graph/models.py", line 5, in <module>
karrio     |     from karrio.server.manager.models import Customs, Parcel, Address
karrio     |   File "/karrio/venv/lib/python3.8/site-packages/karrio/server/manager/models.py", line 8, in <module>
karrio     |     from karrio.server.core.utils import identity
karrio     |   File "/karrio/venv/lib/python3.8/site-packages/karrio/server/core/utils.py", line 14, in <module>
karrio     |     from karrio.server.core import datatypes, serializers
karrio     |   File "/karrio/venv/lib/python3.8/site-packages/karrio/server/core/serializers.py", line 2, in <module>
karrio     |     from drf_yasg import openapi
karrio     |   File "/karrio/venv/lib/python3.8/site-packages/drf_yasg/openapi.py", line 11, in <module>
karrio     |     from .utils import dict_has_ordered_keys, filter_none, force_real_str
karrio     |   File "/karrio/venv/lib/python3.8/site-packages/drf_yasg/utils.py", line 17, in <module>
karrio     |     from rest_framework.views import APIView
karrio     |   File "/karrio/venv/lib/python3.8/site-packages/rest_framework/views.py", line 17, in <module>
karrio     |     from rest_framework.schemas import DefaultSchema
karrio     |   File "/karrio/venv/lib/python3.8/site-packages/rest_framework/schemas/__init__.py", line 33, in <module>
karrio     |     authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES,
karrio     |   File "/karrio/venv/lib/python3.8/site-packages/rest_framework/settings.py", line 225, in __getattr__
karrio     |     val = perform_import(val, attr)
karrio     |   File "/karrio/venv/lib/python3.8/site-packages/rest_framework/settings.py", line 168, in perform_import
karrio     |     return [import_from_string(item, setting_name) for item in val]
karrio     |   File "/karrio/venv/lib/python3.8/site-packages/rest_framework/settings.py", line 168, in <listcomp>
karrio     |     return [import_from_string(item, setting_name) for item in val]
karrio     |   File "/karrio/venv/lib/python3.8/site-packages/rest_framework/settings.py", line 180, in import_from_string
karrio     |     raise ImportError(msg)
karrio     | ImportError: Could not import 'karrio.server.core.authentication.TokenBasicAuthentication' for API setting 'DEFAULT_AUTHENTICATION_CLASSES'. ModuleNotFoundError: No module named 'yaml'.
karrio exited with code 1
@danh91
Copy link
Member

danh91 commented Aug 8, 2022

Hi @adrianmihaila ,

Thank you so much for reporting it.
I just fixed the dependency and pushed a new version 2022.6.2

https://hub.docker.com/repository/docker/karrio/server/tags?page=1&ordering=last_updated
https://hub.docker.com/repository/docker/karrio/dashboard/tags?page=1&ordering=last_updated

Let me know if everything is ok

Thanks

@danh91 danh91 closed this as completed Aug 8, 2022
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