ERROR: Could not build wheels for safetensors, tokenizers, which is required to install pyproject.toml-based projects
Author: zhaosheng-thu
Pull request: no

### System Info

`pip install transformers`

### Who can help?

_No response_

### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [X] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

When I am installing transformers-4.35.2, the problems happen.
Building wheels for collected packages: safetensors, tokenizers
  Building wheel for safetensors (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for safetensors (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [45 lines of output]
      Running `maturin pep517 build-wheel -i D:\pycharm312\venv\Scripts\python.exe --compatibility off`
      馃嵐 Building a mixed python/rust project
      馃敆 Found pyo3 bindings
      馃悕 Found CPython 3.12 at D:\pycharm312\venv\Scripts\python.exe
      馃摗 Using build options features, bindings from pyproject.toml
         Compiling proc-macro2 v1.0.70
         Compiling target-lexicon v0.12.12
         Compiling unicode-ident v1.0.12
         Compiling autocfg v1.1.0
         Compiling once_cell v1.18.0
         Compiling windows_x86_64_msvc v0.48.5
         Compiling syn v1.0.109
         Compiling libc v0.2.150
         Compiling parking_lot_core v0.9.9
         Compiling serde v1.0.193
         Compiling cfg-if v1.0.0
         Compiling scopeguard v1.2.0
         Compiling smallvec v1.11.2
         Compiling serde_json v1.0.108
         Compiling itoa v1.0.9
         Compiling ryu v1.0.15
         Compiling unindent v0.1.11
      error: linker `link.exe` not found
        |
        = note: program not found

      note: the msvc targets depend on the msvc linker but `link.exe` was not found

      note: please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option.

      note: VS Code is a different product, and is not sufficient.

      error: could not compile `proc-macro2` (build script) due to previous error
      warning: build failed, waiting for other jobs to finish...
      error: could not compile `target-lexicon` (build script) due to previous error
      error: could not compile `windows_x86_64_msvc` (build script) due to previous error
      error: could not compile `syn` (build script) due to previous error
      error: could not compile `libc` (build script) due to previous error
      error: could not compile `parking_lot_core` (build script) due to previous error
      error: could not compile `serde` (build script) due to previous error
      error: could not compile `serde_json` (build script) due to previous error
      馃挜 maturin failed
        Caused by: Failed to build a native library through cargo
        Caused by: Cargo build finished with "exit code: 101": `"cargo" "rustc" "--features" "pyo3/extension-module" "--message-format" "json-render-diagnostics"
 "--manifest-path" "C:\\Users\\86186\\AppData\\Local\\Temp\\pip-install-b9fju0sq\\safetensors_2de969c81fb9425fbfef7449546ec30d\\bindings\\python\\Cargo.toml" "--release" "--lib"`
      Error: command ['maturin', 'pep517', 'build-wheel', '-i', 'D:\\pycharm312\\venv\\Scripts\\python.exe', '--compatibility', 'off'] returned non-zero exit status 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for safetensors
  Building wheel for tokenizers (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for tokenizers (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [43 lines of output]
      Running `maturin pep517 build-wheel -i D:\pycharm312\venv\Scripts\python.exe --compatibility off`
      馃嵐 Building a mixed python/rust project
      馃敆 Found pyo3 bindings
      馃悕 Found CPython 3.12 at D:\pycharm312\venv\Scripts\python.exe
      馃摗 Using build options features, bindings from pyproject.toml
         Compiling autocfg v1.1.0
         Compiling proc-macro2 v1.0.69
         Compiling unicode-ident v1.0.12
         Compiling windows_x86_64_msvc v0.48.5
         Compiling cfg-if v1.0.0
         Compiling syn v1.0.109
         Compiling target-lexicon v0.12.12
         Compiling scopeguard v1.2.0
         Compiling libc v0.2.150
         Compiling crossbeam-utils v0.8.16
         Compiling cc v1.0.83
         Compiling once_cell v1.18.0
         Compiling memchr v2.6.4
         Compiling fnv v1.0.7
         Compiling windows_x86_64_msvc v0.42.2
         Compiling strsim v0.10.0
      error: linker `link.exe` not found
        |
        = note: program not found

      note: the msvc targets depend on the msvc linker but `link.exe` was not found

      note: please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option.

      note: VS Code is a different product, and is not sufficient.

      error: could not compile `windows_x86_64_msvc` (build script) due to previous error
      warning: build failed, waiting for other jobs to finish...
      error: could not compile `proc-macro2` (build script) due to previous error
      error: could not compile `windows_x86_64_msvc` (build script) due to previous error
      error: could not compile `crossbeam-utils` (build script) due to previous error
      error: could not compile `target-lexicon` (build script) due to previous error
      error: could not compile `libc` (build script) due to previous error
      error: could not compile `syn` (build script) due to previous error
      馃挜 maturin failed
        Caused by: Failed to build a native library through cargo
        Caused by: Cargo build finished with "exit code: 101": `"cargo" "rustc" "--features" "pyo3/extension-module" "--message-format" "json-render-diagnostics"
 "--manifest-path" "C:\\Users\\86186\\AppData\\Local\\Temp\\pip-install-b9fju0sq\\tokenizers_1ea38977042a4a4194501ec96394a1a0\\bindings\\python\\Cargo.toml" "--release" "--lib"`
      Error: command ['maturin', 'pep517', 'build-wheel', '-i', 'D:\\pycharm312\\venv\\Scripts\\python.exe', '--compatibility', 'off'] returned non-zero exit status 1
      [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 safetensors tokenizers
ERROR: Could not build wheels for safetensors, tokenizers, which is required to install pyproject.toml-based projects  

versions:
    pip: 23.3.1
    setuptools: 69.0.2
    wheel: 0.38.4
they are updated to the latest version.
how can i solve it? Thanks!

### Expected behavior

how can i solve it? Thanks!

Comments:
hey which version of python are you working with? And what hardware are you using? 

> hey which version of python are you working with? And what hardware are you using?

thanks a lot! I have just solved this problem, and wish you a good day!

How did you solve this?


> hey which version of python are you working with? And what hardware are you using?

i am getting same issue. i am using python 3.12

@Hassaan-Qaisar , @Tolder99 , @zhaosheng-thu do you have any solution for that?

manually install maturin (pip download maturin==1.76), then pip install transformers --no-deps