ImportError: CamembertTokenizer requires the SentencePiece library but it was not found in your environment

173 Views Asked by At

I try to create a .exe from a Python code. Here is my .spec:

# -*- mode: python ; coding: utf-8 -*-

from PyInstaller.utils.hooks import copy_metadata

datas = [("C:/Users/pierr/OneDrive/Bureau/Projet_perso/Traitement BPU 2.1/BT42.xlsx","."),
    ("C:/Users/pierr/OneDrive/Bureau/Projet_perso/Traitement BPU 2.1/finetuned_camembert/*", "finetuned_camembert"),
    ("C:/Users/pierr/OneDrive/Bureau/Projet_perso/Traitement BPU 2.1/donnees_embeddings.npy","."),
    ("C:/Users/pierr/OneDrive/Bureau/Projet_perso/Traitement BPU 2.1/donnees_gagnanteslabels.xlsx","."),
    ("C:/Users/pierr/OneDrive/Bureau/Projet_perso/Traitement BPU 2.1/données_gagnants_labels_sans_autres.xlsx","."),
    ("C:/Users/pierr/OneDrive/Bureau/Projet_perso/Traitement BPU 2.1/données_test.xlsx","."),
    ("C:/Users/pierr/OneDrive/Bureau/Projet_perso/Traitement BPU 2.1/exemple.png","."),
    ("C:/Users/pierr/OneDrive/Bureau/Projet_perso/Traitement BPU 2.1/venv/lib/site-packages/sentencepiece/*","sentencepiece")]
datas += copy_metadata('tqdm')
datas += copy_metadata('transformers')
datas += copy_metadata('regex')
datas += copy_metadata('sacremoses')
datas += copy_metadata('requests')
datas += copy_metadata('packaging')
datas += copy_metadata('filelock')
datas += copy_metadata('numpy')
datas += copy_metadata('tokenizers')
datas += copy_metadata('importlib_metadata')

block_cipher = None

a = Analysis(['main.py'],
         pathex=["C:/Users/pierr/OneDrive/Bureau/Projet_perso"],
         binaries=[("C:/Users/pierr/Documents/Lib/site-packages/torch/lib/torch_python.dll", "."),
                   ("C:/Users/pierr/Documents/Lib/site-packages/torch/lib/torch_cpu.dll", "."),
                   ("C:/Users/pierr/Documents/Lib/site-packages/torch/lib/c10.dll", "."),
                   ("C:/Users/pierr/OneDrive/Bureau/Projet_perso/Traitement BPU 2.1/venv/Lib/site-packages/sentencepiece/_sentencepiece.cp37-win_amd64.pyd", "."),
                   ("C:/Users/pierr/AppData/Local/Packages/PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0/LocalCache/local-packages/Python39/site-packages/tensorflow/python/_pywrap_tensorflow_internal.pyd", ".")],
         datas=datas,
         hiddenimports=["scikit-learn", "tqdm", "transformers", "sentencepiece"],
         hookspath=[],
         runtime_hooks=[],
         excludes=[],
         win_no_prefer_redirects=False,
         win_private_assemblies=False,
         cipher=block_cipher,
         noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
         cipher=block_cipher)
exe = EXE(pyz,
      a.scripts,
      a.binaries,
      a.zipfiles,
      a.datas,
      [],
      name='main',
      debug=False,
      bootloader_ignore_signals=False,
      strip=False,
      upx=True,
      upx_exclude=[],
      runtime_tmpdir=None,
      console=True , icon='C:/Users/pierr/Downloads/logo_sef.ico')

And this the error I got when I launched my .exe :

(venv)          C:\Users\pierr\OneDrive\Bureau\Projet_perso\Traitement BPU 2.1\dist>main.exe
    None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only       tokenizers, configuration and file/data utilities can be used.
    Traceback (most recent call last):
      File "main.py", line 8, in <module>
      File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
      File "core_2.py", line 29, in <module>
      File "transformers\utils\import_utils.py", line 1026, in __getattribute__
      File "transformers\utils\import_utils.py", line 1014, in requires_backends
    ImportError:
CamembertTokenizer requires the SentencePiece library but it was not found in your environment.   Checkout the instructions on the        
installation page of its repo: https://github.com/google/sentencepiece#installation and follow the ones
    that match your environment. Please note that you may need to restart your runtime after installation.

    [46776] Failed to execute script 'main' due to unhandled exception!
0

There are 0 best solutions below