pythonpython-importvisual-studio-codehuggingface-transformers

Huggingface Transformers not getting imported in VS Code


My VS Code Editor for Python is not able to import transformers even though I have done a conda install and giving me the following error

Traceback (most recent call last):
  File "c:/Users/I323017/Documents/Studies/question_answering_kinnal/src/main.py", line 3, in <module>
    import transformers
  File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\transformers\__init__.py", line 107, in <module>
    from .pipelines import (
  File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\transformers\pipelines.py", line 40, in <module>
    from .tokenization_auto import AutoTokenizer
  File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\transformers\tokenization_auto.py", line 49, in <module>
    from .tokenization_flaubert import FlaubertTokenizer
  File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\transformers\tokenization_flaubert.py", line 23, in <module>
    from .tokenization_xlm import XLMTokenizer
  File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\transformers\tokenization_xlm.py", line 26, in <module>
    import sacremoses as sm
  File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\sacremoses\__init__.py", line 2, in <module>
    from sacremoses.tokenize import *
  File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\sacremoses\tokenize.py", line 10, in <module>
    from sacremoses.util import is_cjk
  File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\sacremoses\util.py", line 11, in <module>
    from joblib import Parallel, delayed
ModuleNotFoundError: No module named 'joblib'

May I know the problem here?


Solution

  • This seems to be an installation issue. If you have already installed transformers using conda install -c conda-forge transformers, an additional upgradation from the source using the below resolved my issue.

    git clone https://github.com/huggingface/transformers.git
    cd transformers
    pip install .