# Value error : sentencepiece

**URL:** <https://discuss.huggingface.co/t/value-error-sentencepiece/4313>\
**Category:** Beginners\
**Created:** [March 11, 2021, 3:15pm UTC](https://discuss.huggingface.co/t/value-error-sentencepiece/4313 "2021-03-11T15:15:51Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Katarina](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@Katarina](https://discuss.huggingface.co/u/Katarina)\
**Post date:** [March 11, 2021, 3:15pm UTC](https://discuss.huggingface.co/t/value-error-sentencepiece/4313/1 "2021-03-11T15:15:51Z")

</div>

Hi,

I have value error: This tokenizer cannot be instantiated. Please make sure you have `sentencepiece` installed in order to use this tokenizer.

I installed and updated `sentencepiece` (0.1.95) but still getting the same error. Can someone help?  
Thank you!

---

<div class="post-metadata">

**Author:** ![lewtun](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lewtun/32/30995_2.png) [@lewtun](https://discuss.huggingface.co/u/lewtun)\
**Post date:** [March 11, 2021, 8:27pm UTC](https://discuss.huggingface.co/t/value-error-sentencepiece/4313/2 "2021-03-11T20:27:21Z")

</div>

Hi @Katarina, what happens if you try installing `transformers` in a new environment with

```auto
pip install transformers[sentencepiece]

```

Does that solve the problem?

---

<div class="post-metadata">

**Author:** ![Katarina](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@Katarina](https://discuss.huggingface.co/u/Katarina)\
**Post date:** [March 12, 2021, 7:58am UTC](https://discuss.huggingface.co/t/value-error-sentencepiece/4313/3 "2021-03-12T07:58:48Z")

</div>

Hi, thanks on answer…I tried with this but still the same error

---

<div class="post-metadata">

**Author:** ![lewtun](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lewtun/32/30995_2.png) [@lewtun](https://discuss.huggingface.co/u/lewtun)\
**Post date:** [March 12, 2021, 8:23am UTC](https://discuss.huggingface.co/t/value-error-sentencepiece/4313/4 "2021-03-12T08:23:20Z")

</div>

Can you please share the code you are running and the full stack trace / error message?

---

<div class="post-metadata">

**Author:** ![Katarina](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@Katarina](https://discuss.huggingface.co/u/Katarina)\
**Post date:** [March 12, 2021, 11:11am UTC](https://discuss.huggingface.co/t/value-error-sentencepiece/4313/5 "2021-03-12T11:11:27Z")

</div>

Acctually it is working after I restarted my enviroment…thank you!

---

<div class="post-metadata">

**Author:** ![imflash217](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/imflash217/32/3981_2.png) [@imflash217](https://discuss.huggingface.co/u/imflash217)\
**Post date:** [February 10, 2022, 1:57am UTC](https://discuss.huggingface.co/t/value-error-sentencepiece/4313/6 "2022-02-10T01:57:38Z")

</div>

This works:

```bash
pip install sentencepiece

```

---

<div class="post-metadata">

**Author:** ![shamim237](https://avatars.discourse-cdn.com/v4/letter/s/a87d85/32.png) [@shamim237](https://discuss.huggingface.co/u/shamim237)\
**Post date:** [November 6, 2022, 5:07pm UTC](https://discuss.huggingface.co/t/value-error-sentencepiece/4313/7 "2022-11-06T17:07:40Z")

</div>

use this one-

`pip install transformers[sentencepiece] datasets`

---

<div class="post-metadata">

**Author:** ![yahiaelgamal](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/yahiaelgamal/32/14111_2.png) [@yahiaelgamal](https://discuss.huggingface.co/u/yahiaelgamal)\
**Post date:** [February 13, 2023, 4:31pm UTC](https://discuss.huggingface.co/t/value-error-sentencepiece/4313/8 "2023-02-13T16:31:32Z")

</div>

this has to do with you shell actually. You are probably using zsh if you are on Mac, and you are getting `zsh: no matches found: transformers[sentencepiece]`.

Solution: `pip install "transformers[sentencepiece]"`

---

<div class="post-metadata">

**Author:** ![payagil9](https://avatars.discourse-cdn.com/v4/letter/p/cc9497/32.png) [@payagil9](https://discuss.huggingface.co/u/payagil9)\
**Post date:** [June 23, 2023, 5:44am UTC](https://discuss.huggingface.co/t/value-error-sentencepiece/4313/9 "2023-06-23T05:44:09Z")

</div>

Fix: ` pip install transformers[sentencepiece]`  
if it is installed and still getting error, restart the kernel

---

<div class="post-metadata">

**Author:** ![maheswarareddy](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/maheswarareddy/32/21241_2.png) [@maheswarareddy](https://discuss.huggingface.co/u/maheswarareddy)\
**Post date:** [November 16, 2023, 1:54pm UTC](https://discuss.huggingface.co/t/value-error-sentencepiece/4313/10 "2023-11-16T13:54:42Z")

</div>

Kernel Restart solved this problem.

---

<div class="post-metadata">

**Author:** ![marabgol](https://avatars.discourse-cdn.com/v4/letter/m/df705f/32.png) [@marabgol](https://discuss.huggingface.co/u/marabgol)\
**Post date:** [December 2, 2023, 4:03am UTC](https://discuss.huggingface.co/t/value-error-sentencepiece/4313/11 "2023-12-02T04:03:05Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![Arunmass](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/arunmass/32/23409_2.png) [@Arunmass](https://discuss.huggingface.co/u/Arunmass)\
**Post date:** [January 29, 2024, 5:13am UTC](https://discuss.huggingface.co/t/value-error-sentencepiece/4313/12 "2024-01-29T05:13:12Z")

</div>

Use pip install transformers[sentencepiece]

And restart the kernel. It will work 🙂

---

<div class="post-metadata">

**Author:** ![YaBoyBigPat](https://avatars.discourse-cdn.com/v4/letter/y/58956e/32.png) [@YaBoyBigPat](https://discuss.huggingface.co/u/YaBoyBigPat)\
**Post date:** [August 10, 2024, 10:33pm UTC](https://discuss.huggingface.co/t/value-error-sentencepiece/4313/13 "2024-08-10T22:33:07Z")

</div>

I also found that using conda install works. I had to do conda install sentencepiece and conda install protobuf to get it to work for me.

---

<div class="post-metadata">

**Author:** ![CChung-at-VSA](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/cchung-at-vsa/32/53048_2.png) [@CChung-at-VSA](https://discuss.huggingface.co/u/CChung-at-VSA)\
**Post date:** [September 24, 2024, 5:48am UTC](https://discuss.huggingface.co/t/value-error-sentencepiece/4313/14 "2024-09-24T05:48:43Z")

</div>

Besides conda install sentencepiece, I found that I can do conda install sentence-transformers which pull in sentencepiece also.

---

<div class="post-metadata">

**Author:** ![sphynxlee](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sphynxlee/32/33433_2.png) [@sphynxlee](https://discuss.huggingface.co/u/sphynxlee)\
**Post date:** [October 25, 2024, 5:50pm UTC](https://discuss.huggingface.co/t/value-error-sentencepiece/4313/15 "2024-10-25T17:50:34Z")

</div>

# Yes, I met this issue either. My platform is below: MacOS 15.0.1 Python 3.12.6 pip 24.2

Then I executed this command:

```auto
pip3 install sentencepiece

```

And restarted Kernel, then it works

---

<div class="post-metadata">

**Author:** ![coldllama](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/coldllama/32/51579_2.png) [@coldllama](https://discuss.huggingface.co/u/coldllama)\
**Post date:** [July 23, 2025, 6:09pm UTC](https://discuss.huggingface.co/t/value-error-sentencepiece/4313/16 "2025-07-23T18:09:16Z")

</div>

For those who find this thread before others across the web, sentencepiece is currently failling install in python 3.13. Other threads suggest that installing 3.12 can resolve the issue and allow for the install to complete.

> `sentencepiece` does not support `python 3.13` yet.  
> Its latest version was released on Feb 19, 2024.  
> You need to downgrade to `python 3.12`  
> **[sentencepiece · PyPI](https://pypi.org/project/sentencepiece/)**

also, for those new to python, you can have more than one python version installed at the same time.

> If you have multiple versions of python installed, don’t forget to use “py --list” to see which ones you got. As an example, after discovering that the issue is with python 3.13, I explicitly told it to use update 3.11 as follows: “py -3.11 -m pip install -r requirements.txt” This got through the sentencepiece part of my requirements file

quotes copied from [here](https://stackoverflow.com/questions/78009310/i-can-not-install-sentencepiece-how-to-solve-it)
