PyInstaller Transformers runtime import error
Hi,

I am getting the following error while creating executable with transformers using PyInstaller

**PyInstaller: 4.3
Transformers Version: 4.6.0
736 INFO: Python: 3.8.5 (conda)
751 INFO: Platform: macOS-10.15.5**

_413560 INFO: Packages required by datasets:
['dill', 'multiprocess', 'pandas', 'tqdm', 'tqdm', 'requests', 'xxhash', 'pyarrow', 'numpy']
445137 INFO: Packages required by filelock:
[]
File "", line 2
import huggingface-hub as p
^
SyntaxError: invalid syntax
Traceback (most recent call last):
File "/Users/xxxxx/opt/anaconda3/envs/xxxxxx/lib/python3.8/site-packages/PyInstaller/utils/hooks/init.py", line 358, in get_module_file_attribute
attr = loader.get_filename(package)
AttributeError: 'NoneType' object has no attribute 'get_filename'_

transformers hook file as follows,

```
from PyInstaller.utils.hooks import collect_all

def hook(hook_api):
packages = [
'transformers',
# "Pillow",
# "black==21.4b0",
# "cookiecutter==1.7.2",
"dataclasses",
"datasets",
# "deepspeed>=0.3.16",
# "docutils==0.16.0",
# "fairscale>0.3",
# "faiss-cpu",
# "fastapi",
"filelock",
# "flake8>=3.8.3",
# "flax>=0.3.2",
# "fugashi>=1.0",
"huggingface-hub",
"importlib_metadata",
# "ipadic>=1.0.0,<2.0",
# "isort>=5.5.4",
# "jax>=0.2.8",
# "jaxlib>=0.1.59",
# "jieba",
# "keras2onnx",
# "nltk",
"numpy",
# "onnxconverter-common",
# "onnxruntime-tools>=1.4.2",
# "onnxruntime>=1.4.0",
"packaging",
# "parameterized",
# "protobuf",
# "psutil",
# "pydantic",
# "pytest",
# "pytest-sugar",
# "pytest-xdist",
# "python>=3.6.0",
# "recommonmark",
"regex",
"requests",
# "rouge-score",
# "sacrebleu>=1.4.12",
"sacremoses",
# "sagemaker>=2.31.0",
# "scikit-learn",
# "sentencepiece==0.1.91",
# "soundfile",
# "sphinx-copybutton",
# "sphinx-markdown-tables",
# "sphinx-rtd-theme==0.4.3", # sphinx-rtd-theme==0.5.0 introduced big changes in the style.
# "sphinx==3.2.1",
# "sphinxext-opengraph==0.4.1",
# "starlette",
# "tensorflow-cpu>=2.3",
# "tensorflow>=2.3",
# "timeout-decorator",
"tokenizers",
# "torch>=1.0",
# "torchaudio",
"tqdm",
# "unidic>=1.0.2",
# "unidic_lite>=1.0.7",
# "uvicorn",
]

for package in packages:
    datas, binaries, hiddenimports = collect_all(package)
    hook_api.add_datas(datas)
    hook_api.add_binaries(binaries)
    hook_api.add_imports(*hiddenimports)
```
Hi, the error seems to originate from PyInstaller rather than `transformers`, right? Have you reported it to the PyInstaller team?<|||||>> Hi, the error seems to originate from PyInstaller rather than `transformers`, right? Have you reported it to the PyInstaller team?

Yes @LysandreJik, I posted the same question in PyInstaller as well. But PyInstaller is working with other libraries like torch, tensroflow. It's only failing with Transformers library as it is checking the versions of all dependent libraries. Not sure exact reason.<|||||>This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.