learningequality / kolibri

Kolibri Learning Platform: the offline app for universal education
https://learningequality.org/kolibri/
MIT License
808 stars 682 forks source link

Issue with Kolibri: ModuleNotFoundError for `pkg_resources` #12499

Closed niefeiyang closed 3 months ago

niefeiyang commented 3 months ago

Issue with Kolibri: ModuleNotFoundError for pkg_resources


Observed behavior

When attempting to run Kolibri, I encountered a ModuleNotFoundError for pkg_resources. After installing setuptools (I first asked ChatGPT to help, which mentioned the error may caused by lack of pip module 'setuptools'), another error occurred, indicating a missing django.utils.six.moves module. Below are the error details:

Initial Error:

Traceback (most recent call last):
  File "/home/feiyang/playground/kolibri/bin/kolibri", line 5, in <module>
    from kolibri.utils.cli import main
  File "/home/feiyang/playground/kolibri/lib/python3.12/site-packages/kolibri/__init__.py", line 11, in <module>
    from kolibri.utils.version import get_version
  File "/home/feiyang/playground/kolibri/lib/python3.12/site-packages/kolibri/utils/version.py", line 107, in <module>
    from .compat import parse_version
  File "/home/feiyang/playground/kolibri/lib/python3.12/site-packages/kolibri/utils/compat.py", line 10, in <module>
    from pkg_resources import parse_version as _parse_version
ModuleNotFoundError: No module named 'pkg_resources'

Error after installing setuptools:

INFO: No C extensions are available for this platform
Traceback (most recent call last):
  File "/home/feiyang/playground/kolibri/bin/kolibri", line 5, in <module>
    from kolibri.utils.cli import main
  File "/home/feiyang/playground/kolibri/lib/python3.12/site-packages/kolibri/utils/cli.py", line 12, in <module>
    from django.core.management import execute_from_command_line
  File "/home/feiyang/playground/kolibri/lib/python3.12/site-packages/kolibri/dist/django/core/management/__init__.py", line 10, in <module>
    from django.apps import apps
  File "/home/feiyang/playground/kolibri/lib/python3.12/site-packages/kolibri/dist/django/apps/__init__.py", line 1, in <module>
    from .config import AppConfig
  File "/home/feiyang/playground/kolibri/lib/python3.12/site-packages/kolibri/dist/django/apps/config.py", line 4, in <module>
    from django.core.exceptions import ImproperlyConfigured
  File "/home/feiyang/playground/kolibri/lib/python3.12/site-packages/kolibri/dist/django/core/exceptions.py", line 5, in <module>
    from django.utils.encoding import force_text
  File "/home/feiyang/playground/kolibri/lib/python3.12/site-packages/kolibri/dist/django/utils/encoding.py", line 11, in <module>
    from django.utils.six.moves.urllib.parse import quote, unquote
ModuleNotFoundError: No module named 'django.utils.six.moves'

Errors and logs

Command Line Logs:

(kolibri) [feiyang@pwnbox kolibri]$ kolibri
Traceback (most recent call last):
  File "/home/feiyang/playground/kolibri/bin/kolibri", line 5, in <module>
    from kolibri.utils.cli import main
  File "/home/feiyang/playground/kolibri/lib/python3.12/site-packages/kolibri/__init__.py", line 11, in <module>
    from kolibri.utils.version import get_version
  File "/home/feiyang/playground/kolibri/lib/python3.12/site-packages/kolibri/utils/version.py", line 107, in <module>
    from .compat import parse_version
  File "/home/feiyang/playground/kolibri/lib/python3.12/site-packages/kolibri/utils/compat.py", line 10, in <module>
    from pkg_resources import parse_version as _parse_version
ModuleNotFoundError: No module named 'pkg_resources'

Expected behavior

Kolibri should start without encountering ModuleNotFoundError for pkg_resources or django.utils.six.moves.

User-facing consequences

Users are unable to start Kolibri, which prevents access to its functionalities and services.

Steps to reproduce

  1. Set up a Python virtual environment.
  2. Install Kolibri using pip.
  3. Attempt to run Kolibri using the kolibri command.
mkdir kolibri
python -m venv kolibri
cd kolibri
source bin/activate
pip install kolibri

Context


rtibbles commented 3 months ago

Could you show the output of pip freeze here, so we can see what kolibri version is installed?

If you just did pip install kolibri then it would presumably be installing 0.16.2 which is the latest version released to pypi, which does not support Python 3.12 (so I am a little surprised it let you install), but good to check.

niefeiyang commented 3 months ago

(kolibri) [feiyang@pwnbox kolibri]$ pip freeze kolibri==0.15.1

rtibbles commented 3 months ago

So, as a heads up, no currently released version of Kolibri supports Python 3.12. 0.17.0, which will be released either this week or next week will do so.

I am unsure how to handle the setuptools issue though, as it is needed at installation time as well as at runtime, so it would be insufficient to add it to our requirements.

niefeiyang commented 3 months ago

Thank you. You did a great job on this.