Transformers: Installation example #2 fails: cannot import name 'glue_compute_metrics'

Created on 8 Oct 2019  路  6Comments  路  Source: huggingface/transformers

馃悰 Bug

I am having issues with the official installation procedure, where running python -m pytest -sv ./examples fails with an opaque error message (below).

To Reproduce

Steps to reproduce the behavior:

  1. Create virtualenv
  2. Install Pytorch (pip install torch==1.2.0+cpu torchvision==0.4.0+cpu -f https://download.pytorch.org/whl/torch_stable.html)
  3. Install transformers (pip install transformers)
  4. Install pytest (pip install pytest)
  5. Run python -m pytest -sv ./transformers/tests/; no tests fail
  6. Run python -m pytest -sv ./examples/; fails requiring tensorboardX
  7. Install tensorboardX (pip install tensorboardX)
  8. Run python -m pytest -sv ./examples/; fails with message:
==================================== ERRORS ====================================
__________________ ERROR collecting examples/test_examples.py __________________
ImportError while importing test module '/home/evancw/Projects/transformers/examples/test_examples.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
examples/test_examples.py:30: in <module>
    import run_glue
examples/run_glue.py:49: in <module>
    from transformers import glue_compute_metrics as compute_metrics
E   ImportError: cannot import name 'glue_compute_metrics'
!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.64s ===============================

Expected behavior

I would expect the tests to pass.

Environment

  • OS: Ubuntu 18.04.3 LTS
  • Python version: 3.6.8
  • PyTorch version: 1.2.0 + CPU
  • PyTorch Transformers version (or branch): 2.0.0
  • Using GPU ? No
  • Distributed of parallel setup ? No
  • Any other relevant information: System is completely clean before pip installs

Additional context

Please let me know if there is any more information I can provide.

Most helpful comment

Could we add this to the getting started documentation?

pip install -r ./examples/requirements.txt

All 6 comments

@evanweissburg Hi, i got the same error..have you found any solution???

Hello! I believe you must have sklearn installed in order to pass these tests. Please let me know if it doesn't work while having sklearn installed.

yeah got it .... i guess we need to run pip install -r ./examples/requirements.txt

Indeed!

Could we add this to the getting started documentation?

pip install -r ./examples/requirements.txt

Had the same issue. Probably a problem with sklearn. Installed with conda and it was fixed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chuanmingliu picture chuanmingliu  路  3Comments

lcswillems picture lcswillems  路  3Comments

quocnle picture quocnle  路  3Comments

alphanlp picture alphanlp  路  3Comments

zhezhaoa picture zhezhaoa  路  3Comments