Search code examples
pythonrusthuggingface-tokenizers

Building wheel for tokenizers (pyproject.toml) did not run successfully - Python 3.9.9 - Windows 10


Yes there are several other questions like this but no solution provided

I am trying to install and run this project

https://github.com/xashru/punctuation-restoration

I have cloned the github repository

Installed rust from here downloading x64 : https://www.rust-lang.org/tools/install

I am using

Python 3.9.9 (tags/v3.9.9:ccb0e6a, Nov 15 2021, 18:08:50) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

Here the error message I am getting



  Compiling lock_api v0.3.4
         Compiling strsim v0.8.0
           Running `rustc --crate-name lock_api --edition=2018 C:\Users\King\.cargo\registry\src\github.com-1ecc6299db9ec823\lock_api-0.3.4\src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --cfg "feature=\"nightly\"" -C metadata=2fe17ee22c58d967 -C extra-filename=-2fe17ee22c58d967 --out-dir C:\Users\King\AppData\Local\Temp\pip-install-b7_bo2sd\tokenizers_1b6098a3d736487c996866dfd304f880\target\release\deps -L dependency=C:\Users\King\AppData\Local\Temp\pip-install-b7_bo2sd\tokenizers_1b6098a3d736487c996866dfd304f880\target\release\deps --extern scopeguard=C:\Users\King\AppData\Local\Temp\pip-install-b7_bo2sd\tokenizers_1b6098a3d736487c996866dfd304f880\target\release\deps\libscopeguard-38978501dffc7e67.rmeta --cap-lints allow`
           Running `rustc --crate-name strsim C:\Users\King\.cargo\registry\src\github.com-1ecc6299db9ec823\strsim-0.8.0\src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -C metadata=8fb9b7eda8bf3ac7 -C extra-filename=-8fb9b7eda8bf3ac7 --out-dir C:\Users\King\AppData\Local\Temp\pip-install-b7_bo2sd\tokenizers_1b6098a3d736487c996866dfd304f880\target\release\deps -L dependency=C:\Users\King\AppData\Local\Temp\pip-install-b7_bo2sd\tokenizers_1b6098a3d736487c996866dfd304f880\target\release\deps --cap-lints allow`
      error[E0557]: feature has been removed
        --> C:\Users\King\.cargo\registry\src\github.com-1ecc6299db9ec823\lock_api-0.3.4\src\lib.rs:91:42
         |
      91 | #![cfg_attr(feature = "nightly", feature(const_fn))]
         |                                          ^^^^^^^^ feature has been removed
         |
         = note: split into finer-grained feature gates

      For more information about this error, try `rustc --explain E0557`.
      error: could not compile `lock_api` due to previous error

      Caused by:
        process didn't exit successfully: `rustc --crate-name lock_api --edition=2018 C:\Users\King\.cargo\registry\src\github.com-1ecc6299db9ec823\lock_api-0.3.4\src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --cfg "feature=\"nightly\"" -C metadata=2fe17ee22c58d967 -C extra-filename=-2fe17ee22c58d967 --out-dir C:\Users\King\AppData\Local\Temp\pip-install-b7_bo2sd\tokenizers_1b6098a3d736487c996866dfd304f880\target\release\deps -L dependency=C:\Users\King\AppData\Local\Temp\pip-install-b7_bo2sd\tokenizers_1b6098a3d736487c996866dfd304f880\target\release\deps --extern scopeguard=C:\Users\King\AppData\Local\Temp\pip-install-b7_bo2sd\tokenizers_1b6098a3d736487c996866dfd304f880\target\release\deps\libscopeguard-38978501dffc7e67.rmeta --cap-lints allow` (exit code: 1)
      warning: build failed, waiting for other jobs to finish...
      error: `cargo rustc --lib --message-format=json-render-diagnostics --manifest-path Cargo.toml --release -v --features pyo3/extension-module -- --crate-type cdylib` failed with code 101
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for tokenizers
Failed to build tokenizers
ERROR: Could not build wheels for tokenizers, which is required to install pyproject.toml-based projects

C:\punctuation-restoration>

it was too big to paste here : https://justpaste.it/7uen0


Solution

  • As far as I can see it comes down to a version conflict. The versions of transformers and tokenizers are severly out of date.

    On the rust side, that means that a rust feature (const_fn) tokenizers is using, is by now part of rust and not a nightly feature anymore (this is what the error output shows the compiler is complaining about).

    In my eyes you have two main options:

    • updating the dependencies
    • install a very specific rust version

    To update the dependencies manually change the requirements.txt and change the version numbers of transformers (and tokenizers). Ideally to the newest version. This might or might not work, depending on the repository, since they might depend HARD on that version of transformers / tokenizers. I would still try it out in your case, as this is the easy option.

    Setting a sepecific rust version could be another way. You need to use a tool like rustup to install an older rust version that is compatible with the install. This means checking that specific version of tokenizers and see if they referred to the rust version or otherwise going by the commit timestamp to install the proper rust version of this time. This should work, but will of course use a lot of old libs and rust, so definitely not advised if you can get it to work otherwise.