Error while upgrading tutor & Open edX from Maple to Lilac: ImportError: cannot import name 'SCHEME_KEYS' from 'pip._internal.models.scheme'

Hi all,

I am running tutor version 12.1.7 and I want to upgrade it to the latest version (13.1.0).

Following the official documentation, I run the following:

pip install --upgrade tutor[full]
tutor config save
tutor images build all

But at step 37/103 : RUN pip install -r ./requirements/edx/base.txt of the command tutor images build all I am encountering the following error:

Traceback (most recent call last):
  File "/openedx/venv/bin/pip", line 5, in <module>
    from pip._internal.cli.main import main
  File "/openedx/venv/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/openedx/venv/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/openedx/venv/lib/python3.8/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>    from pip._internal.cli import cmdoptions
  File "/openedx/venv/lib/python3.8/site-packages/pip/_internal/cli/cmdoptions.py", line 25, in <module>    from pip._internal.locations import USER_CACHE_DIR, get_src_prefix
  File "/openedx/venv/lib/python3.8/site-packages/pip/_internal/locations/__init__.py", line 7, in <module>
    from pip._internal.models.scheme import SCHEME_KEYS, Scheme
ImportError: cannot import name 'SCHEME_KEYS' from 'pip._internal.models.scheme' (/openedx/venv/lib/python3.8/site-packages/pip/_internal/models/scheme.py)
The command '/bin/sh -c pip install -r ./requirements/edx/base.txt' returned a non-zero code: 1
Error: Command failed with status 1: docker build -t docker.io/overhangio/openedx:13.1.0 /home/ubuntu/.local/share/tutor/env/build/openedx

So far, I have not seen this python error reported many times on forums. This post https://www.linuxquestions.org/questions/suse-opensuse-60/pip-cannot-import-name-scheme_key-4175702998/ suggests to upgrade pip but /openedx/venv/bin/pip seems to be downgraded by tutor one step earlier during the upgrade process:

Step 36/103 : RUN pip install setuptools==44.1.0 pip==20.0.2 wheel==0.34.2
 ---> Running in d958811993fe
Collecting setuptools==44.1.0
  Downloading setuptools-44.1.0-py2.py3-none-any.whl (583 kB)
Collecting pip==20.0.2
  Downloading pip-20.0.2-py2.py3-none-any.whl (1.4 MB)
Collecting wheel==0.34.2
  Downloading wheel-0.34.2-py2.py3-none-any.whl (26 kB)
Installing collected packages: wheel, setuptools, pip
  Attempting uninstall: setuptools
    Found existing installation: setuptools 56.0.0
    Uninstalling setuptools-56.0.0:
      Successfully uninstalled setuptools-56.0.0
  Attempting uninstall: pip
    Found existing installation: pip 21.1.1
    Uninstalling pip-21.1.1:
      Successfully uninstalled pip-21.1.1
Successfully installed pip-20.0.2 setuptools-44.1.0 wheel-0.34.2
Removing intermediate container d958811993fe

Has anyone ever encountered a similar issue?

Thanks in advance!

I haven’t encountered this error before, I would suggest to pull the images instead of building the images, you could just let tutor pull them unless for sure you are using a customized image for openedx

Hi @ghassanmas, thank you for your reply. The problem is that I am using custom translations (my platform is in French) and so if I understood well the documentation, I have no choice but to build the images.

You should definitely be able to build the Docker images yourself.

Can you tell from the logs which package is causing the installation to fail? I am unable to reproduce the issue. Are you building a fork of edx-platform? If yes, what changes did you make?

No I am not building a fork of the edx-platform. The customizations I made of the platform are:

  1. custom translations in $(tutor config printroot)/env/build/openedx/locale/fr/LC_MESSAGES
  2. indigo theme
  3. 2 custom yaml plugins
  4. 1 XBlock from appsembler

(Hope I did not forget anything but I don’t think so)

Unfortunately, I did not see any other error in the logs than what I reported in my initial post. I will try again by uninstalling the XBlock maybe.

I restored a past snapshot of my server to try to understand what is wrong.

When I run pip freeze before runinng any upgrade comand (including pip install --upgrade tutor[full]) here is what I obtain:

tutor==12.1.7
tutor-android==12.0.1
tutor-contrib-codejail==12.0.2
tutor-openedx==12.0.1

I tried to install the android and codejail plugins few months ago but I encountered some issues so I eventually disabled the plugins. Just to be sure, I uninstalled both plugins before doing anything else:

pip uninstall tutor-android
pip uninstall tutor-contrib-codejail

I then run pip install --upgrade tutor[full]. After that, here is what pip freeze displays:

tutor==13.1.1
tutor-android==13.0.0
tutor-discovery==13.0.0
tutor-ecommerce==13.0.0
tutor-forum==13.0.0
tutor-license==13.0.0
tutor-mfe==13.0.1
tutor-minio==13.0.0
tutor-notes==13.0.0
tutor-openedx==12.0.1
tutor-richie==13.0.0
tutor-webui==13.0.0
tutor-xqueue==13.0.0

The surprising thing in the above list is tutor-openedx==12.0.1. I tried to uninstall this package since in another post, @regis said it is a transition package and can safely be uninstalled. The problem is that after I run pip uninstall tutor-openedx, the command tutor is removed : /home/ubuntu/.local/bin/tutor: No such file or directory.

Could it be that there is something with my current installation of tutor that is causing the issue I described in my original post (see above) ? (conflicting versions of tutor or something ?)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.