Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError on dvc pull in Alpine env #2334

Closed
AlexJoz opened this issue Jul 28, 2019 · 17 comments
Closed

ImportError on dvc pull in Alpine env #2334

AlexJoz opened this issue Jul 28, 2019 · 17 comments

Comments

@AlexJoz
Copy link
Contributor

AlexJoz commented Jul 28, 2019

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

@efiop
Copy link
Contributor

efiop commented Jul 28, 2019

Hi @AlexJoz ! Thanks for reporting this! This is pretty weird, I am able to reproduce this with your dockerfile, but it works fine for me locally with the same yaml version. Looking into it.

@efiop
Copy link
Contributor

efiop commented Jul 28, 2019

Looks like the issue is not on our side, more tailored reproducer

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 ruamel.yaml
RUN python3 -c 'from ruamel.yaml import YAML'

shows that there is something wrong with ruamel itself. Mind opening an issue in ruamel too please?

@efiop
Copy link
Contributor

efiop commented Jul 28, 2019

For the record ruamel.yaml==0.15.100 works fine.

@AlexJoz
Copy link
Contributor Author

AlexJoz commented Jul 28, 2019

@efiop, ok!
Thanks for a quick response =)

@ghost
Copy link

ghost commented Jul 28, 2019

@efiop , could it be related to alpine using musl libc? 🤔

@ghost
Copy link

ghost commented Jul 28, 2019

@efiop, check tout he following: https://bitbucket.org/ruamel/yaml/commits/tag/0.16.0
split off C library into separate package

it doesn't seem like a relevant update.

@AlexJoz , a quick workaround would be to install ruamel.yaml before dvc, like the following:

FROM python:alpine

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 'ruamel.yaml==0.15.100'
RUN pip3 install dvc[gs]
RUN python3 -c 'from ruamel.yaml import YAML'

If you create an issue in the ruamel.yaml repo, please let us know :)
And, indeed, thanks for reporting this!

@ghost ghost added the build label Jul 28, 2019
@AvdN
Copy link

AvdN commented Jul 28, 2019

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.

@AlexJoz
Copy link
Contributor Author

AlexJoz commented Jul 28, 2019

@AvdN Cool, thanx!

@MrOutis
seems a bit late, but lets link: https://bitbucket.org/ruamel/yaml/issues/299 =))

@efiop
Copy link
Contributor

efiop commented Jul 28, 2019

@AvdN Thank you! 🙂

@AlexJoz Btw, maybe you'd like to submit a quick fix for ruamel.yaml<0.16 in our setup.py? 😉 I'll release a new dvc version with it right after that.

@efiop
Copy link
Contributor

efiop commented Jul 28, 2019

@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 🙂

@efiop
Copy link
Contributor

efiop commented Jul 28, 2019

@AlexJoz FYI: 0.53.2 is out. Please feel free to upgrade! 🙂

@AlexJoz
Copy link
Contributor Author

AlexJoz commented Jul 28, 2019

@efiop already done =) Works fine! Thanks

@AvdN
Copy link

AvdN commented Aug 7, 2019

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
Copy link
Contributor

efiop commented Aug 7, 2019

@AvdN Great news! Thank you so much!

@efiop
Copy link
Contributor

efiop commented Aug 8, 2019

It would be best to wait for the next ruamel.yaml release, which, I suppose, will have updated requirements for clib. But if it works for you @AlexJoz already, we could relax the requirements right away without waiting for the next release.

@AvdN
Copy link

AvdN commented Aug 8, 2019

@efiop There is a new ruamel.yaml. (0.16.1) which has that requirement

@efiop
Copy link
Contributor

efiop commented Aug 8, 2019

@AvdN Oh, that is perfect! Thank you!

@efiop efiop closed this as completed in f8673e7 Aug 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants