Internal Server Error 7.1.3 no module named captcha.fields

Despite installing with pip3 install fields, the problem still shows it being missing.

2020-04-07 17:46:04,885 [ERROR] django.request:135 handle_uncaught_exception Internal Server Error: /api2/repos/
Traceback (most recent call last):
  File "/opt/marma/seafile-server-7.1.3/seahub/thirdpart/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/opt/marma/seafile-server-7.1.3/seahub/thirdpart/django/core/handlers/base.py", line 244, in _legacy_get_response
    response = middleware_method(request)
  File "/opt/marma/seafile-server-7.1.3/seahub/thirdpart/django/middleware/locale.py", line 24, in process_request
    i18n_patterns_used, prefixed_default_language = is_language_prefix_patterns_used(urlconf)
  File "/opt/marma/seafile-server-7.1.3/seahub/thirdpart/django/conf/urls/i18n.py", line 29, in is_language_prefix_patterns_used
    for url_pattern in get_resolver(urlconf).url_patterns:
  File "/opt/marma/seafile-server-7.1.3/seahub/thirdpart/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/opt/marma/seafile-server-7.1.3/seahub/thirdpart/django/urls/resolvers.py", line 407, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/opt/marma/seafile-server-7.1.3/seahub/thirdpart/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/opt/marma/seafile-server-7.1.3/seahub/thirdpart/django/urls/resolvers.py", line 400, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/opt/marma/seafile-server-7.1.3/seahub/seahub/utils/rooturl.py", line 41, in <module>
    url(r'^%s' % settings.SITE_ROOT[1:], include(settings.SITE_ROOT_URLCONF)),
  File "/opt/marma/seafile-server-7.1.3/seahub/thirdpart/django/conf/urls/__init__.py", line 50, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/opt/marma/seafile-server-7.1.3/seahub/seahub/urls.py", line 8, in <module>
    from seahub.views.sysadmin import *
  File "/opt/marma/seafile-server-7.1.3/seahub/seahub/views/sysadmin.py", line 96, in <module>
    from seahub.utils.two_factor_auth import has_two_factor_auth
  File "/opt/marma/seafile-server-7.1.3/seahub/seahub/utils/two_factor_auth.py", line 5, in <module>
    from seahub.two_factor.views.login import (
  File "/opt/marma/seafile-server-7.1.3/seahub/seahub/two_factor/views/__init__.py", line 2, in <module>
    from .core import SetupView, BackupTokensView, SetupCompleteView, QRGeneratorView
  File "/opt/marma/seafile-server-7.1.3/seahub/seahub/two_factor/views/core.py", line 31, in <module>
    from seahub.auth.forms import AuthenticationForm
  File "/opt/marma/seafile-server-7.1.3/seahub/seahub/auth/forms.py", line 17, in <module>
    from captcha.fields import CaptchaField
ModuleNotFoundError: No module named 'captcha.fields'

Usually upgrades for Seafile is stable, it seems this one has a lot of things missing from the upgrade documentation to make it work. What needs to be done to fix this?

1 Like

I fixed this error using:
pip3 install django-simple-captcha
pip3 install django-recaptcha
pip3 install captcha
This is my first day using seafile though, so no warranty that this is a best-practice approach.
The seafile-manual should be updated. It’s instructions are still for python2, it took me a while to sort everything out.

I did also try the recaptcha, although still get the error relating to captcha.fields. I’ll check/verify later though, since the server is currently in use, so will know more in the evening.

@manolen actually had already tried that, still same error about captcha.fields so definitely still a load of things missing for 7.1.3 to work.

Impossible to upgrade with lack of documentation upgrade procedures and missing modules to install. Let’s hope the Seafile team will be forthcoming with a solution for this asap.

@manolen actually different module now since the one before. Now CaptchaField instead of captcha.fields

2020-04-08 15:47:18,097 [ERROR] django.request:135 handle_uncaught_exception Internal Server Error: /api2/events/
Traceback (most recent call last):
  File "/opt/marma/seafile-server-7.1.3/seahub/thirdpart/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/opt/marma/seafile-server-7.1.3/seahub/thirdpart/django/core/handlers/base.py", line 244, in _legacy_get_response
    response = middleware_method(request)
  File "/opt/marma/seafile-server-7.1.3/seahub/thirdpart/django/middleware/locale.py", line 24, in process_request
    i18n_patterns_used, prefixed_default_language = is_language_prefix_patterns_used(urlconf)
  File "/opt/marma/seafile-server-7.1.3/seahub/thirdpart/django/conf/urls/i18n.py", line 29, in is_language_prefix_patterns_used
    for url_pattern in get_resolver(urlconf).url_patterns:
  File "/opt/marma/seafile-server-7.1.3/seahub/thirdpart/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/opt/marma/seafile-server-7.1.3/seahub/thirdpart/django/urls/resolvers.py", line 407, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/opt/marma/seafile-server-7.1.3/seahub/thirdpart/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/opt/marma/seafile-server-7.1.3/seahub/thirdpart/django/urls/resolvers.py", line 400, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/opt/marma/seafile-server-7.1.3/seahub/seahub/utils/rooturl.py", line 41, in <module>
    url(r'^%s' % settings.SITE_ROOT[1:], include(settings.SITE_ROOT_URLCONF)),
  File "/opt/marma/seafile-server-7.1.3/seahub/thirdpart/django/conf/urls/__init__.py", line 50, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/opt/marma/seafile-server-7.1.3/seahub/seahub/urls.py", line 8, in <module>
    from seahub.views.sysadmin import *
  File "/opt/marma/seafile-server-7.1.3/seahub/seahub/views/sysadmin.py", line 96, in <module>
    from seahub.utils.two_factor_auth import has_two_factor_auth
  File "/opt/marma/seafile-server-7.1.3/seahub/seahub/utils/two_factor_auth.py", line 5, in <module>
    from seahub.two_factor.views.login import (
  File "/opt/marma/seafile-server-7.1.3/seahub/seahub/two_factor/views/__init__.py", line 2, in <module>
    from .core import SetupView, BackupTokensView, SetupCompleteView, QRGeneratorView
  File "/opt/marma/seafile-server-7.1.3/seahub/seahub/two_factor/views/core.py", line 31, in <module>
    from seahub.auth.forms import AuthenticationForm
  File "/opt/marma/seafile-server-7.1.3/seahub/seahub/auth/forms.py", line 17, in <module>
    from captcha.fields import CaptchaField
ImportError: cannot import name 'CaptchaField'

Well, I’ve managed to figure this out now. The problems are caused if you have already installed from Ubuntu’s repositories any of the above modules from the Seafile documentation.

So, the way to resolve it, is check if you have any of the modules installed from the Ubuntu repositories, and if so, remove them. Then, when those conflicts have been removed, run this command from the 7.1 upgrade readme.

pip3 install --timeout=3600 Pillow pylibmc captcha jinja2 sqlalchemy psd-tools django-pylibmc django-simple-captcha python3-ldap

so just ensure, any of the above modules are not installed before running the pip3 command.

2 Likes

I’m happy that you solved it. Sorry that I was not of much help. I hope the seafile team will update the installation instruction!

In case someone ends up finding this thread like me:

Based on ianw1974’s answer, this package was the issue in my case: python3-django-captcha

I fixed it like this:
apt remove python3-django-captcha
and then
pip3 install django-simple-captcha

1 Like

This worked for me during update from 7.0.5 to 7.1.4 on Ubuntu 18.0.4.4 LTS.
Thanks

1 Like

After spending way too much time with a failed upgrade from 7.0.5 to 7.1.4, this finally helped me get over the hump. Thanks!

All other upgrades have been seamless (been with Seafile since 6.2.3), but this one was a huge disappointment.