python HuggingFace Transformers未安装在VS Code中

rmbxnbpk  于 2023-10-15  发布在  Python
关注(0)|答案(4)|浏览(169)

我是VS代码和一般编码的新手,我一直试图安装transformers,命令pip install transformerspip install transformers[tf-cpu]都不起作用,错误如下:

Building wheel for tokenizers (pyproject.toml) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\TevaJ\Desktop\Projects\venv\Scripts\python.exe' 'C:\Users\TevaJ\Desktop\Projects\venv\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' build_wheel 'C:\Users\TevaJ\AppData\Local\Temp\tmps54vamjd'
       cwd: C:\Users\TevaJ\AppData\Local\Temp\pip-install-kolpujzg\tokenizers_befed87ed1a749f8a23369cfa56db8a2
  Complete output (19 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.10
  creating build\lib.win-amd64-3.10\tokenizers
  copying tokenizers\__init__.py -> build\lib.win-amd64-3.10\tokenizers
  running build_ext
  error: can't find Rust compiler

  If you are using an outdated pip version, it is possible a prebuilt wheel is available for this package but pip is not able to install from it. Installing from the wheel would avoid the need for a Rust compiler.

  To update pip, run:

      pip install --upgrade pip

  and then retry package installation.

  If you did intend to build this package from source, try installing a Rust compiler from your system package manager and ensure it is on the PATH during installation. Alternatively, rustup (available at https://rustup.rs) is the recommended way to download and update the Rust compiler toolchain.
  ----------------------------------------
  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
(venv) PS C:\Users\TevaJ\Desktop\Projects>

我在google上查了一下,但找不到解决办法。有谁知道这个错误以及如何修复它?

pcww981p

pcww981p1#

解决了
只需要从源代码安装它,而不依赖于PIP 619。

git clone https://github.com/huggingface/transformers.git 
cd transformers
pip install -e .
gcuhipw9

gcuhipw92#

另一个可能的解决方案是安装Rust编译器,重新启动并再次尝试pip install。

r7knjye2

r7knjye23#

我尝试以下命令。

conda install -c huggingface transformers
wz1wpwve

wz1wpwve4#

你不能用pip安装Transformers版本>2.3.0,在安装rust编译器后,尝试用conda安装。
“conda install transformers”或“conda install -c huggingface transformers”

相关问题