Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Not able to import flash as transformer.__spec__ is returning None #614

Closed
prikmm opened this issue Jul 27, 2021 · 1 comment · Fixed by #615
Closed

Not able to import flash as transformer.__spec__ is returning None #614

prikmm opened this issue Jul 27, 2021 · 1 comment · Fixed by #615
Labels
bug / fix Something isn't working help wanted Extra attention is needed

Comments

@prikmm
Copy link

prikmm commented Jul 27, 2021

🐛 Bug

I am trying to complete a summarization project and decided to use flash for it but am getting import error as transformers.__spec__ is returning None. I have opened huggingface/transformers#12904 issue on transformers page meanwhile, would like to know if there's a possible workaround to it.

Code sample

import transformers
print(transformers.__version__)
print(transformers.__spec__)

import flash

OUTPUT:

4.8.2
None
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-d02f1c770adc> in <module>
      3 print(transformers.__spec__)
      4 
----> 5 import flash

/opt/conda/lib/python3.7/site-packages/flash/__init__.py in <module>
     16 
     17 from flash.__about__ import *  # noqa: F401 F403
---> 18 from flash.core.utilities.imports import _TORCH_AVAILABLE
     19 
     20 if _TORCH_AVAILABLE:

/opt/conda/lib/python3.7/site-packages/flash/core/utilities/imports.py in <module>
     75 _PYTORCHVIDEO_AVAILABLE = _module_available("pytorchvideo")
     76 _MATPLOTLIB_AVAILABLE = _module_available("matplotlib")
---> 77 _TRANSFORMERS_AVAILABLE = _module_available("transformers")
     78 _PYSTICHE_AVAILABLE = _module_available("pystiche")
     79 _FIFTYONE_AVAILABLE = _module_available("fiftyone")

/opt/conda/lib/python3.7/site-packages/flash/core/utilities/imports.py in _module_available(module_path)
     36     """
     37     try:
---> 38         return find_spec(module_path) is not None
     39     except AttributeError:
     40         # Python 3.6

/opt/conda/lib/python3.7/importlib/util.py in find_spec(name, package)
    112         else:
    113             if spec is None:
--> 114                 raise ValueError('{}.__spec__ is None'.format(name))
    115             return spec
    116 

ValueError: transformers.__spec__ is None

Expected behavior

Able to import flash

Environment

  • PyTorch Version (e.g., 1.0): 3.7.0/3.8.1
  • OS (e.g., Linux):
  • Platform: Colab/Kaggle
  • How you installed PyTorch (conda, pip, source):
  • Build command you used (if compiling from source):
  • Python version:
  • CUDA/cuDNN version:
  • GPU models and configuration:
  • Any other relevant information:

Additional context

@prikmm prikmm added bug / fix Something isn't working help wanted Extra attention is needed labels Jul 27, 2021
@ethanwharris
Copy link
Collaborator

Hi @prikmm, thanks for reporting this. I've just added something to catch the error so hopefully it shouldn't break any more. Could you try installing from github with:

pip install git+https://github.com/PytorchLightning/lightning-flash.git@master

Let me know if that fixes the issue 😃

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug / fix Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants