label-studio-ml-backend icon indicating copy to clipboard operation
label-studio-ml-backend copied to clipboard

ContextualVersionConflict MarkupSafe 2.0.0 versus moto

Open arianpasquali opened this issue 3 years ago • 10 comments

There seems to be a requeriments version conflict related to dependencies MarkupSafe and moto. These are not direct dependencies but they make the system fail.

After following the readme instructions to install it

cd label-studio-ml-backend

# Install label-studio-ml and its dependencies
pip install -U -e .

# Install example dependencies
pip install -r label_studio_ml/examples/requirements.txt

it fails to run label-studio-ml init my_ml_backend --script label_studio_ml/examples/simple_text_classifier.py

label-studio-ml init my_ml_backend   --script label_studio_ml/examples/simple_text_classifier.py
Traceback (most recent call last):
  File "/root/workspace/label-studio-ml-backend/dev/lib/python3.8/site-packages/pkg_resources/__init__.py", line 583, in _build_master
    ws.require(__requires__)
  File "/root/workspace/label-studio-ml-backend/dev/lib/python3.8/site-packages/pkg_resources/__init__.py", line 900, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/root/workspace/label-studio-ml-backend/dev/lib/python3.8/site-packages/pkg_resources/__init__.py", line 791, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (MarkupSafe 2.0.0 (/root/workspace/label-studio-ml-backend/dev/lib/python3.8/site-packages), Requirement.parse('MarkupSafe<2.0'), {'moto'})

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/workspace/label-studio-ml-backend/dev/bin/label-studio-ml", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/root/workspace/label-studio-ml-backend/dev/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3252, in <module>
    def _initialize_master_working_set():
  File "/root/workspace/label-studio-ml-backend/dev/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3235, in _call_aside
    f(*args, **kwargs)
  File "/root/workspace/label-studio-ml-backend/dev/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3264, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/root/workspace/label-studio-ml-backend/dev/lib/python3.8/site-packages/pkg_resources/__init__.py", line 585, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/root/workspace/label-studio-ml-backend/dev/lib/python3.8/site-packages/pkg_resources/__init__.py", line 598, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/root/workspace/label-studio-ml-backend/dev/lib/python3.8/site-packages/pkg_resources/__init__.py", line 786, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'MarkupSafe<2.0' distribution was not found and is required by moto

arianpasquali avatar May 12 '21 17:05 arianpasquali

@arianpasquali could you make a PR with a fix of this bug please?

makseq avatar May 12 '21 18:05 makseq

Quick fix was to remove moto dependency from label-studio,

ignore this dependency moto==1.3.16.dev122

at https://github.com/heartexlabs/label-studio/blob/master/deploy/requirements.txt#L31

moto seems to be a testing dependency, however this was a quick fix and this is probably not the final solution.

after fixing this one we still have left an issue with responses library, but this one is not urgent.

Warning!!! Possibly conflicting dependencies found:
* responses==0.13.3
 - urllib3 [required: >=1.25.10, installed: 1.25.8]

arianpasquali avatar May 12 '21 21:05 arianpasquali

Not sure how to fix this for good instead of this workaround. For a more elegant dependency management do we consider moving from pip to poetry?

arianpasquali avatar May 13 '21 10:05 arianpasquali

@arianpasquali poetry is a good software, but most of our users use pip..

makseq avatar May 13 '21 21:05 makseq

I face this version conflict issue also and I use pip, any update or solution on this? Thanks.

Edit: The quickfix provided by arianpasquali works, just curious any solution without manually remove moto dependancy.

hj1643 avatar May 19 '21 14:05 hj1643

Hi,

I have same problem. I try to uninstall moto like @arianpasquali said but it's not working. Do you have any solution or update for this issue?

Thanks in advance

amoussoubaruch avatar May 27 '21 13:05 amoussoubaruch

Hi @amoussoubaruch, try to create a virtual environment, manually install Label Studio in that environment by removing 'moto==1.3.16.dev122' in requirements.txt as mentioned above. Hope it helps.

hj1643 avatar May 31 '21 06:05 hj1643

Having the same issue here. I tried what @arianpasquali said about removing moto dependecy and when i execute

label-studio-ml init my_ml_backend --script label_studio_ml/examples/simple_text_classifier.py

I get the error:

/usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.5) or chardet (3.0.4) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
Traceback (most recent call last):
  File "/home/facephi/.local/bin/label-studio-ml", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3254, in <module>
    def _initialize_master_working_set():
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3237, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3266, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 584, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 901, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 787, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'moto==1.3.16.dev122' distribution was not found and is required by label-studio

AntonioBriPerez avatar Jun 04 '21 12:06 AntonioBriPerez

@AntonioBriPerez @hj1643 @amoussoubaruch @arianpasquali I moved moto to requirements-test.txt, so it should be ok now. Please, check it in this branch: https://github.com/heartexlabs/label-studio/pull/1020

makseq avatar Jun 04 '21 12:06 makseq

Hi all,

I solve this issue by removing 'moto==1.3.16.dev122' in requirements.txt. It's work fine

@makseq thanks. I will pull new version and try with that.

amoussoubaruch avatar Jun 04 '21 14:06 amoussoubaruch

Closed as outdated and probably solved.

makseq avatar Mar 09 '23 17:03 makseq