dvc: ImportError on `dvc pull` in Alpine env
dvc pull
fails in Docker based on Alpine 3.10 with latest dvc (0.53.1)
Traceback (most recent call last):
File "/usr/bin/dvc", line 6, in <module>
from dvc.main import main
File "/usr/lib/python3.7/site-packages/dvc/__init__.py", line 11, in <module>
import dvc.logger
File "/usr/lib/python3.7/site-packages/dvc/logger.py", line 5, in <module>
from dvc.utils.compat import str, StringIO
File "/usr/lib/python3.7/site-packages/dvc/utils/__init__.py", line 29, in <module>
from ruamel.yaml import YAML
ImportError: cannot import name 'YAML' from 'ruamel.yaml' (/usr/lib/python3.7/site-packages/ruamel/yaml/__init__.py)
Dockerfile to reproduce:
FROM alpine:3.10
RUN apk add --update build-base python3 python3-dev zlib-dev jpeg-dev linux-headers git bash
RUN pip3 install --no-cache-dir --upgrade pip
RUN pip3 install dvc[gs]
RUN dvc pull my.dvc
Going through history, found commit after which this error has appeared. Basically, using ruamel.yaml ver. 0.15.9 fixes the issue.
Latest working tag:
pip3 install dvc[gs]==0.40.0
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (12 by maintainers)
I set the issue on bitbucket to resolved, as I think this got fixed by releasing a new version of ruamel.yaml.clib (you should use ruamel.yaml.clib>=0.1.2). Unless you have pinned the previous version of ruamel.yaml.clib, clean rebuilding should now get a working version.
@efiop already done =) Works fine! Thanks
@AlexJoz Big thanks for the fix! I’ll trigger the release in a moment. Let’s keep this issue open until ruamel.yaml is fixed, so we don’t forget to update requirements in dvc 🙂
This almost certainly has to do with ruamel.yaml having been split it up and the second package (ruamel.yaml.clib which contains the C loader/dumper) installing an init.py and .pth file (which it shouldn’t). It might be a few days before I can look into this, you should pin to “ruamel.yaml<0.16” until this is resolved.
@efiop , could it be related to alpine using musl libc? 🤔