Skip to content
This repository has been archived by the owner on Jul 27, 2024. It is now read-only.

librephotos-backend start error: TypeError: 'type' object is not subscriptable #56

Open
cahaya42 opened this issue Feb 9, 2023 · 4 comments

Comments

@cahaya42
Copy link

cahaya42 commented Feb 9, 2023

To install librephotos, I made a fresh install of Ubuntu 20.04.5 LTS in VirtualBox.
I solved a couple of issues (postgresql user & secret.key) but now I'm stuck on TypeError: 'type' object is not subscriptable error.

# service librephotos-backend status
● librephotos-backend.service - librephotos-backend
     Loaded: loaded (/etc/systemd/system/librephotos-backend.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2023-02-09 15:57:48 ACDT; 5h 57min ago
       Docs: https://github.com/LibrePhotos/librephotos
   Main PID: 1038 (bash)
      Tasks: 7 (limit: 38428)
     Memory: 495.2M
     CGroup: /system.slice/librephotos-backend.service
             ├─1038 bash /usr/lib/librephotos/bin/librephotos-backend
             ├─1614 /usr/bin/python3 /usr/bin/gunicorn --workers=2 --worker-class=gevent --timeout 3600 --bind 127.0.0.1:8001 --log-level=info ownphotos.wsgi
             ├─1615 tee /var/log/librephotos//gunicorn_django.log
             ├─1617 /usr/bin/python3 /usr/bin/gunicorn --workers=2 --worker-class=gevent --timeout 3600 --bind 127.0.0.1:8001 --log-level=info ownphotos.wsgi
             └─1618 /usr/bin/python3 /usr/bin/gunicorn --workers=2 --worker-class=gevent --timeout 3600 --bind 127.0.0.1:8001 --log-level=info ownphotos.wsgi

Feb 09 16:16:54 photos librephotos-backend[1615]:     from api.serializers.album_auto import AlbumAutoListSerializer, AlbumAutoSerializer
Feb 09 16:16:54 photos librephotos-backend[1615]:   File "/usr/lib/librephotos/backend/api/serializers/album_auto.py", line 4, in <module>
Feb 09 16:16:54 photos librephotos-backend[1615]:     from api.serializers.person import PersonSerializer
Feb 09 16:16:54 photos librephotos-backend[1615]:   File "/usr/lib/librephotos/backend/api/serializers/person.py", line 5, in <module>
Feb 09 16:16:54 photos librephotos-backend[1615]:     from api.serializers.photos import GroupedPhotosSerializer
Feb 09 16:16:54 photos librephotos-backend[1615]:   File "/usr/lib/librephotos/backend/api/serializers/photos.py", line 133, in <module>
Feb 09 16:16:54 photos librephotos-backend[1615]:     class PhotoSerializer(serializers.ModelSerializer):
Feb 09 16:16:54 photos librephotos-backend[1615]:   File "/usr/lib/librephotos/backend/api/serializers/photos.py", line 209, in PhotoSerializer
Feb 09 16:16:54 photos librephotos-backend[1615]:     def get_image_path(self, obj) -> list[str]:
Feb 09 16:16:54 photos librephotos-backend[1615]: TypeError: 'type' object is not subscriptable

The same error occurs in the /var/log/librephotos/gunicorn_django.log file when launch the site for the first time in a web browser.

2023-02-09 05:46:54 +0000] [1617] [ERROR] Error handling request /api/firsttimesetup/
Traceback (most recent call last):
  File "/usr/lib/librephotos/.local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/lib/librephotos/.local/lib/python3.8/site-packages/django/core/handlers/base.py", line 167, in _get_response
    callback, callback_args, callback_kwargs = self.resolve_request(request)
  File "/usr/lib/librephotos/.local/lib/python3.8/site-packages/django/core/handlers/base.py", line 290, in resolve_request
    resolver_match = resolver.resolve(request.path_info)
  File "/usr/lib/librephotos/.local/lib/python3.8/site-packages/django/urls/resolvers.py", line 549, in resolve
    for pattern in self.url_patterns:
  File "/usr/lib/librephotos/.local/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/lib/librephotos/.local/lib/python3.8/site-packages/django/urls/resolvers.py", line 593, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/usr/lib/librephotos/.local/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/lib/librephotos/.local/lib/python3.8/site-packages/django/urls/resolvers.py", line 586, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/lib/librephotos/backend/ownphotos/urls.py", line 30, in <module>
    from api.views import (
  File "/usr/lib/librephotos/backend/api/views/album_auto.py", line 11, in <module>
    from api.serializers.album_auto import AlbumAutoListSerializer, AlbumAutoSerializer
  File "/usr/lib/librephotos/backend/api/serializers/album_auto.py", line 4, in <module>
    from api.serializers.person import PersonSerializer
  File "/usr/lib/librephotos/backend/api/serializers/person.py", line 5, in <module>
    from api.serializers.photos import GroupedPhotosSerializer
  File "/usr/lib/librephotos/backend/api/serializers/photos.py", line 133, in <module>
    class PhotoSerializer(serializers.ModelSerializer):
  File "/usr/lib/librephotos/backend/api/serializers/photos.py", line 209, in PhotoSerializer
    def get_image_path(self, obj) -> list[str]:
TypeError: 'type' object is not subscriptable

Any suggestions on how to investigate this further?

@derneuere
Copy link
Member

This is probably an issue with the python version. Should be 3.9 or higher.

@cahaya42
Copy link
Author

The version of python that ships with Ubuntu 20.04 LTS is 3.8.2. Currently on my system I have:

 python3 --version
Python 3.8.10

@derneuere
Copy link
Member

Alright, we have found the issue! I would recommend upgrading to a newer LTS version like Jammy Jellyfish 22.04. If you don't want to, we could create an issue for that instead. Maybe there is a workaround for it.

@cahaya42
Copy link
Author

Since it was a new VM dedicated to LibrePhotos, I've tossed it away and started afresh with Ubuntu 22.04.1 LTS.
After making the changes described in issue #54 and issue #55. The installation ran successfully, the services started and the first setup page was displayed. 😄

Based on this I would recommend:

  1. Python 3.9 is added as a per-requisite (and optionally a check added to the script)
  2. Ubuntu 22.04 LTS is recommended over 20.04

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

No branches or pull requests

2 participants